next up previous contents index
Next: Environment Variables Up: bash Customization Previous: Startup Files


What are some of the things you might want to customize? Here's something that I think about 90% of Bash users have put in their .bashrc:


That command defined a shell alias  called ll that ``expands'' to the normal shell command ``ls -l'' when invoked by the user. So, assuming that Bash has read that command in from your .bashrc, you can just type ll to get the effect of ``ls -l'' in only half the keystrokes. What happens is that when you type ll and hit tex2html_wrap8352 , Bash intercepts it, because it's watching for aliases, replaces it with ``ls -l'', and runs that instead. There is no actual program called ll on the system, but the shell automatically translated the alias into a valid program.

Some sample aliases are in Figure gif. You could put them in your own .bashrc. One especially interesting alias is the first one. With that alias, whenever someone types ls, they automatically have a -F flag tacked on. (The alias doesn't try to expand itself again.) This is a common way of adding options that you use every time you call a program.

Notice the comments with the # character in Figure gif. Whenever a # appears, the shell ignores the rest of the line. 

Figure: Some sample aliases for bash.

You might have noticed a few odd things about them. First of all, I leave off the quotes in a few of the aliases--like pu. Strictly speaking, quotes aren't necessary when you only have one word on the right of the equal sign.

It never hurts to have quotes either, so don't let me get you into any bad habits. You should certainly use them if you're going to be aliasing a command with options and/or arguments:


Also, the final alias has some funky quoting going on:


As you might have guessed, I wanted to pass double-quotes in the options themselves, so I had to quote those with a backslash to prevent bash from thinking that they signaled the end of the alias.

Finally, I have actually aliased two common typing mistakes, ``mroe'' and ``moer'', to the command I meant to type, more. Aliases do not interfere with your passing arguments to a program. The following works just fine:


In fact, knowing how to make your own aliases is probably at least half of all the shell customization you'll ever do. Experiment a little, find out what long commands you find yourself typing frequently, and make aliases for them. You'll find that it makes working at a shell prompt a much more pleasant experience.

next up previous contents index
Next: Environment Variables Up: bash Customization Previous: Startup Files

Converted on:
Mon Apr 1 08:59:56 EST 1996