For the risk-averse among us, here are a few aliases that can reside in your shell initialization as insurance against the accidental removal of a file(s) or folder(s):
alias cp="cp -i"
alias mv="mv -i"
alias rm="rm -i"
.
Simply add them to your ~/.bash_profile
with the following:
printf '%s\n' 'alias cp="cp -i"' 'alias mv="mv -i"' 'alias rm="rm -i"' >>~/.bash_profile
,
being sure to reload your Bash profile by doing: . ~/.bash_profile
Now, when calling the rm
command, for example, rather that carelessly expunging your data, you'll receive an interactive prompt asking you if you want to remove a given file. You can then accept or decline the action as shown here:
Without Alias | With Alias |
---|---|
rm derpy.txt |
rm derpy.txt |
rm: remove regular file'derpy.txt'? |
Aliases need not be limited to "defensive" parameters, though. In fact, they are a useful tool that can save you keystrokes, and by extenstion, time.
Cheers.