Hack #4. Make the Most of Shell Aliases
Make programming easier by programming your shell.
Perl is a language for people who type. It grew up from the shell to write all kinds of programs, but it still rewards people who don't mind launching programs from the command line.
If you spend your time writing Perl from the command line (whether you write short scripts or full-blown programs), spending a few minutes automating common tasks can save you lots of development time—and even more trouble.
Configuring Your Shell
The single most useful shell
trick is the realias command. Normally creating a persistent alias means adding something to your .bashrc (or equivalent) file, starting a new shell, testing it, and then repeating the process until you get it right. Wouldn't it be nice to be able to edit and test a new alias in a single process?
Edit your .bashrc file and add a single line:
source ~/.aliases
Then create the file ~/.aliases, containing:
alias realias='$EDITOR ~/.aliases; source ~/.aliases'
Tip
If you prefer tcsh, edit your .cshrc file. Then replace the = sign with a single space in all of the alias declarations.
Launch a new shell. Type the command realias and your favorite editor (assuming you have the EDITOR environment variable set, and if you don't something is weird) will open with your ~/.aliases file. Add a line and save and quit:
alias reperl='perl -de0'
Now type reperl
[2] at the command line:
$ reperl Loading DB routines from perl5db.pl version 1.28 Editor support available. ...