Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] adding (y/n) rm
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2403
Location: Edmonton, AB

PostPosted: Wed Jan 30, 2013 2:36 am    Post subject: [SOLVED] adding (y/n) rm Reply with quote

How to add option "yes/no" when I type "rm" command?
_________________
#Joseph


Last edited by Joseph_sys on Wed Jan 30, 2013 2:56 am; edited 1 time in total
Back to top
View user's profile Send private message
666threesixes666
Veteran
Veteran


Joined: 31 May 2011
Posts: 1237
Location: 42.68n 85.41w

PostPosted: Wed Jan 30, 2013 2:43 am    Post subject: Reply with quote

produced from "man rm"

-i prompt before every removal

so rm -i file


proof

Code:

mkultra@mksrv [ ~ ]$ touch test
mkultra@mksrv [ ~ ]$ rm -i test
rm: remove regular empty file 'test'? y
mkultra@mksrv [ ~ ]$ stat test
stat: cannot stat 'test': No such file or directory
mkultra@mksrv [ ~ ]$ touch test
mkultra@mksrv [ ~ ]$ rm -i test
rm: remove regular empty file 'test'? n
mkultra@mksrv [ ~ ]$ stat test
  File: 'test'
  Size: 0            Blocks: 0          IO Block: 4096   regular empty file
Device: 808h/2056d   Inode: 1805        Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/ mkultra)   Gid: ( 1000/ mkultra)
Access: 2013-01-29 21:44:11.914907286 -0500
Modify: 2013-01-29 21:44:11.914907286 -0500
Change: 2013-01-29 21:44:11.914907286 -0500
 Birth: -
Back to top
View user's profile Send private message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2403
Location: Edmonton, AB

PostPosted: Wed Jan 30, 2013 2:55 am    Post subject: Reply with quote

666threesixes666 wrote:
produced from "man rm"

-i prompt before every removal

so rm -i file



thanks, I didn't even bother to look-up "man"
I guess adding to .bashrc "alias rm="rm -i" will do the trick.
_________________
#Joseph
Back to top
View user's profile Send private message
666threesixes666
Veteran
Veteran


Joined: 31 May 2011
Posts: 1237
Location: 42.68n 85.41w

PostPosted: Wed Jan 30, 2013 4:13 am    Post subject: Reply with quote

lol u would not believe how absurdly trashed my system is right now. i dont know aliases or exports that well. id get midevil on it and write a full on script before i would alias or export anything. my gnome3's telling me to log out and log back in, and im just running programs on top of it from the cairo-dock life raft.

i dont know how that would work to alias a command with the same alias as the command. if it works shout back, ill do it to my system too as thats been driving me up the wall for a really long time, -I only asks for more than 3 files or recurse so you can delete a single file or two with out being pestered but will stop absurd system trashing
Back to top
View user's profile Send private message
The Doctor
Veteran
Veteran


Joined: 27 Jul 2010
Posts: 1467

PostPosted: Wed Jan 30, 2013 4:19 am    Post subject: Reply with quote

It works. You probably don't realize this, but you have several already set.

Check (but don't modify) /etc/bash/bashrc. you see you already have alias ls='ls --color=auto', alias grep='grep --colour=auto', alias egrep='egrep --colour=auto', and alias fgrep='fgrep --colour=auto' set automatically. Your changes, of course, should go in your user's .bashrc
_________________
First things first, but not necessarily in that order.
Back to top
View user's profile Send private message
666threesixes666
Veteran
Veteran


Joined: 31 May 2011
Posts: 1237
Location: 42.68n 85.41w

PostPosted: Wed Jan 30, 2013 4:40 am    Post subject: Reply with quote

Code:
 mkultra@mksrv [ ~ ]$ cat .bashrc

NORMAL="\[\e[0m\]"
RED="\[\e[1;31m\]"
GREEN="\[\e[1;32m\]"
if [[ $EUID == 0 ]] ; then
  PS1="$RED\u@\h [ $NORMAL\w$RED ]# $NORMAL"
else
  PS1="$GREEN\u@\h [ $NORMAL\w$GREEN ]\$ $NORMAL"
fi


can you give me a hand and show me what your .bashrc looks like i blasted mine away on accident yesterday, my systems seriously rocked right now, gnome wont boot correctly, gdm's totally shot, wicd wont connect, i have to use a crippled gnome3 thats telling me to log out.... i dont have any other users on this system to copy over from, and i suspect roots .bashrc is not the same as the users....

im sorry about the thread jacking im really in a pinch
Back to top
View user's profile Send private message
The Doctor
Veteran
Veteran


Joined: 27 Jul 2010
Posts: 1467

PostPosted: Wed Jan 30, 2013 4:48 am    Post subject: Reply with quote

OK, Here is an abridged version:

Code:
# /etc/skel/.bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output.  So make sure this doesn't display
# anything or bad things will happen !



# Test for an interactive shell.  There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
   # Shell is non-interactive.  Be done now!
   return
fi

# export the root directory so root code works!
export ROOTSYS=/share/apps/root


# Put your fun stuff here.

# portage aliases
alias update="sudo emerge -auvNtD world"
alias clean="sudo emerge -ac"
#alias sync="sudo emerge --sync && sudo layman -S"
alias sync="sudo emerge --sync"
#alias sync="sudo eix-update"
alias recompile="sudo emerge -avt --oneshot "
alias compile="sudo emerge -avt "
alias rebuild="sudo emerge -av @preserved-rebuild"
alias pretend="emerge -pv "

# ssh alias
alias laptop="ssh -Y <username>@<ip>"

# physics alias's
alias fermilab="ssh <username>@<host>"
alias fermilabX="ssh -Y <username>@<host>"
alias tier3="ssh -Y <username>@<host>"
alias tier3X="ssh -Y <username>@<host>"

#skype and wine fun
#alias skype="xhost +local: && sudo -u skype /opt/bin/skype"
alias skype="sh ~/scripts/skype.sh"
alias spotify="sh ~/scripts/spotify.sh"
alias wine="xhost +local: && sudo -u wine /usr/bin/wine"
#alias spotify="xhost +local: && sudo -u wine /usr/bin/wine Spotify.exe"
alias tor="sudo /etc/init.d/tor start"
alias cups="sudo /etc/init.d/cupsd start"


[[ -f "/home/<user>/.config/autopackage/paths-bash" ]] && . "/home/<user>/.config/autopackage/paths-bash"


# Start X unless there is a boot parameter request, active X, or a SSH connection
if [ "$(echo $DISPLAY | wc -w)" -eq "0" -a "$(cat /proc/cmdline | grep nox | wc -l) " -eq "0" ]; then
    if [ -n $SSH_CONNECTION ]; then
   exec nohup startx > /dev/null 2&>1 &
   disown
   exit
   # vlock is not installed, don't use it!
   # exec vlock
    fi
fi

_________________
First things first, but not necessarily in that order.
Back to top
View user's profile Send private message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2403
Location: Edmonton, AB

PostPosted: Wed Jan 30, 2013 5:12 am    Post subject: Reply with quote

666threesixes666 wrote:
Code:
 mkultra@mksrv [ ~ ]$ cat .bashrc

NORMAL="\[\e[0m\]"
RED="\[\e[1;31m\]"
GREEN="\[\e[1;32m\]"
if [[ $EUID == 0 ]] ; then
  PS1="$RED\u@\h [ $NORMAL\w$RED ]# $NORMAL"
else
  PS1="$GREEN\u@\h [ $NORMAL\w$GREEN ]\$ $NORMAL"
fi


can you give me a hand and show me what your .bashrc looks like i blasted mine away on accident yesterday, my systems seriously rocked right now, gnome wont boot correctly, gdm's totally shot, wicd wont connect, i have to use a crippled gnome3 thats telling me to log out.... i dont have any other users on this system to copy over from, and i suspect roots .bashrc is not the same as the users....

im sorry about the thread jacking im really in a pinch


here it is:
Code:
# /etc/skel/.bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output.  So make sure this doesn't display
# anything or bad things will happen !

# This file is sourced by all *interactive* bash shells on startup.  This
# file *should generate no output* or it will break the scp and rcp commands.

# colors for ls, etc.
eval `dircolors -b /etc/DIR_COLORS`
alias d="ls --color"
alias ls="ls --color=auto"
alias ll="ls --color -l -h"
alias thesaurus=aiksaurus
alias rm="rm -I"

# prevent accidental overiting file "echo "text" > file.txt. To force it use ">|" instead of ">"
set -o noclobber

# are we an interactive shell?
if [ "$PS1" ]; then
    case $TERM in
   xterm*)
       PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
       ;;
   *)
       ;;
    esac
    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
fi

# Change the window title of X terminals
case $TERM in
   xterm*|rxvt|Eterm|eterm)
      PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
      ;;
   screen)
      PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
      ;;
esac

##uncomment the following to activate bash-completion:
[ -f /etc/profile.d/bash-completion ] && source /etc/profile.d/bash-completion

export MOZ_NO_REMOTE=1

_________________
#Joseph
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum