In my spare time this weekend, I am beginning to teach myself how to use Terminal. There is a really nice tutorial that I am using. But it seems to be a little outdated in places. It's not taking into account that tcsh has been replaced with bash in Panther. (I confess I don't entirely understand what that even means, but at the very least it seems to mean that some Terminal-related file names are different. For example, when the tutorial speaks of .tcsh_history, it is now .bash_history. However there are still some tcsh-related things around, so I'm not sure when to substitute bash for tcsh and when to leave things alone. There may not be an easily comprehensible rule of thumb for a noob like me, but at the very least I would like a little guidance with this section of the tutorial:
I would like to add these safety features, since I'm new at this at don't want to do anything stupid. But I'm not sure about this .tcshrc file. I don't have one right now. Is it fine to name it this? Should it be .bashrc? Am I making any sense? Help would be much appreciated.
Customising Your Command Line Environment
This section is rather advanced, and you may not understand exactly what is going on. Later tutorials will cover such topics in more depth. For now, I present it merely as an exercise for you to try, and not as a full tutorial. You may skip it if you wish.
There is a hidden file in your home directory called '.tcshrc'. This is a configuration file used by the command line and is read each time a new Terminal is started up.
% cat ~/.tcshrc
will view it. You probably don't have one yet. We can make a new one, or add to the end of an existing one, to customise your command line experience.
If you would like the '-i' option permanently applied to cp, rm, and mv, type the following:
% echo "alias cp cp -i \\!\*" >> ~/.tcshrc
% echo "alias mv mv -i \\!\*" >> ~/.tcshrc
% echo "alias rm rm -i \\!\*" >> ~/.tcshrc
'echo' simply echoes what appears between the quotes. '>> ~/.tcshrc' says to add it to the end of the given file instead of echoing to the Terminal. We are adding lines to the '.tcshrc' file. Each is an alias that tells the command line to substitute 'cp', 'mv', and 'rm' with the text that follows.
Start a new Terminal by pressing cmd-N. When a new Terminal starts it reads the commands in '~/.tcshrc', in this case the three aliases. Now all three commands will be replaced with the '-i' versions given in the aliases, and thus always ask for confirmation before a file is overwritten or deleted.
% touch x y z
% rm x y z
If you wish to temporarily override '-i' when issuing a command, use option '-f'.
% rm -f x y z
If you would like the 'trasher' command described above, type:
% echo "alias trash mv \\!\* ~/.Trash" >> ~/.tcshrc
And if you would like 'less' to be the viewer 'man' uses, type:
% echo "setenv PAGER less" >> ~/.tcshrc
Now start a new Terminal window with cmd-N.
Alternatively, you can edit the '.tcshrc' file with 'pico' if you are familiar with it. In this case, add the following lines to the (new) file:
alias cp cp -i \!\*
alias mv mv -i \!\*
alias rm rm -i \!\*
setenv PAGER less
alias trash mv \!\* ~/.Trash
You can reverse this by removing the lines from the file with an editor, or deleting the file if you never had it in the first palace.
I would like to add these safety features, since I'm new at this at don't want to do anything stupid. But I'm not sure about this .tcshrc file. I don't have one right now. Is it fine to name it this? Should it be .bashrc? Am I making any sense? Help would be much appreciated.