emacs
editor was originally written by Richard Stallman. It is a gigantic, all-purpose, does-everything programming environment. Though readily available, it is seldom installed on most Linux systems by default. lists the meanings of our additions.export HISTCONTROL=ignoredups
Causes the shell’s history recording feature to ignore a command if the same command was just recorded.
export HISTSIZE=1000
Increases the size of the command history from the default of 500 lines to 1000 lines.
alias l.='ls -d .* --color=auto'
Creates a new command called l.
, which displays all directory entries that begin with a dot.
alias ll='ls -l –color=auto'
Creates a new command called ll
, which displays a long-format directory listing.
As we can see, many of our additions are not intuitively obvious, so it would be a good idea to add some comments to our .bashrc file to help explain things to the humans. Using the editor, change our additions to look like this:
# Change umask to make directory sharing easier
umask 0002# Ignore duplicates in command history and increase
# history size to 1000 lines
export HISTCONTROL=ignoredups export HISTSIZE=1000# Add some helpful aliases
alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto'
Ah, much better! With our changes complete, press ctrl-O to save our modified .bashrc file and ctrl-X to exit nano
.
The changes we have made to our .bashrc will not take effect until we close our terminal session and start a new one, because the .bashrc file is only read at the beginning of a session. However, we can force bash
to reread the modified .bashrc file with the following command:
[me@linuxbox ˜]$ source .bashrc
After doing this, we should be able to see the effect of our changes. Try out one of the new aliases:
[me@linuxbox ˜]$ ll
In this chapter we learned an essential skill—editing configuration files with a text editor. Moving forward, as we read man pages for commands, take note of the environment variables that commands support. There may be a gem or two. In later chapters we will learn about shell functions, a powerful feature that you can also include in the bash
startup files to add to your arsenal of custom commands.