Safer file manipulation in the Terminal

May 15, '01 01:39:36PM

Contributed by: Anonymous

By default in OSX, terminal commands like move (mv), copy (cp) or remove (rm) can overwrite or delete existing files without prompting you whether it's really want you want to do. These commands can be dangerous to use especially when using * for designing multiple files. To be automatically prompted for confirmation before each file is processed, create yourself a .cshrc file in your home directory and put the following lines

alias mv 'mv -i'
alias rm 'rm -i'
alias cp 'cp -i'
Another thing I find very useful is to have the target directory listed automatically when issuing a cd command. This can be done as well by adding the following line in your .cshrc file:
alias cd  'cd \!*;echo $cwd; ls -FC'
For these changes to be effective, type source .cshrc or open a new terminal window.

[Editor's note: Please see this related conversation on aliases in another macosxhints' posting. Aliases can live in a number of locations; .tcsh is one of them, but the referenced article gives an alternate, (possibly better?) location for these types of files.]

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20010515133936938