.. highlight:: console .. role:: bash(code) :language: bash :class: highlight Customising the shell --------------------- This section is optional for those who want to make their terminal environment a bit more friendly --- ask the demonstrators for more details if you get this far and have the interest. Setting your :envvar:`PATH` as you learned earlier will only last until you close the terminal. You don't want to have to do that every time you open a shell session! For this, you can add shell snippets to :dfn:`dot files` in your home directory :envvar:`HOME`. Files that start with a dot (\kbd{.}) are usually hidden when you use :command:`ls`, but the :option:`-a` switch will reveal them. Try:: $ ls -a $HOME The important ones for customising :command:`bash` are :file:`.bash_profile` and :file:`.bashrc`. You can read these into the shell (rather than executing them: that would run in a child process and not affect your shell session) using the :command:`source` or :command:`.` command:: $ source ~/.bashrc or :: $ . ~/.bashrc You can also run :command:`reset` to reset your shell which will automatically re-read the setup files. Have a look at the contents of the :file:`.bashrc` file using :command:`less` or :command:`cat` (or :command:`gedit`). Aliases can be used to override commands --- they are a kind of extra layer in command execution before the :envvar:`PATH` gets read. Here's how to set an alias:: $ alias ls="ls -l" That sets an alias which changes :command:`ls` to use the long listing mode by default. Try :command:`ls` now. To access a command and guarantee that you aren't using an alias, you can prefix the command with :command:`command`:: $ command ls You can get rid of this rather annoying alias with :bash:`unalias ls`! Shell functions are like aliases but are a bit more powerful: the main difference is that they can take arguments. Ask for more information.