# bash Configuration¶

All of the Salish Sea MEOPAR documentation assumes that you are using the bash shell. You can check which shell you are using with:

echo $SHELL  If the result is not something like /bin/bash you may be able to start bash with: bash  You may want to request that your IT support change your default shell to bash to avoid having to start bash every time that you open a new shell window/tab. For the Waterhome workstations and salish you can open a ticket with the request on the EOAS Compstaff Helpdesk system. On Westgrid, send an email request to support@westgrid.ca. If you are new to bash or the Linux command line the copy of “The Linux Command Line” by William E. Shotts, Jr. in the Waterhole will help you, as will this Unix Shell Quick Reference page from Software Carpentry. ## .bashrc Snippets¶ bash executes the commands in $HOME/.bashrc every time a new shell window/tab is opened. If you do not have a $HOME/.bashrc file you can create it using your favourite editor. The rest of this section described various snippets of bash code that you may want to include in your $HOME/.bashrc file.

To shorten your prompt so that it shows just the name of the machine that you are on and the directory that you are currently in instead of the whole path to that directory use:

PS1="\h:\W$"  To force programs and commands that want to display output page by page to use less as their pager use: export PAGER=less  To force less to allow control sequences that change the colour of output to work use: export LESS=-R  If you are not a fan of the vi editor you can set the EDITOR and VISUAL environment variables to the command for your favourite editor and export them. For emacs use: export EDITOR=emacs export VISUAL=emacs  The $HOME/bin/ directory is the conventional place keep your own scripts so it is a good idea to add that directory to the end of your PATH:

export PATH=$PATH:$HOME/bin


The $HOME/.local/bin/ directory is where Python scripts installed via the --user option are stored so it should be near the beginning of your PATH: export PATH=$HOME/.local/bin:$PATH  If you are using the Anaconda Python distribution you should add its bin/ directory to the beginning of your PATH: export PATH=$HOME/anaconda3/bin:$PATH  Aliases allow you to run commands with different names or with particular option flags set. To make the ls command use different colours for regular files, executable files, directories, symbolic links, etc., and post-fix characters to indicate those file types use: alias ls="ls --color=auto -F"  To make la include hidden files in file listings use: alias la="ls -a"  To make ll display long file listings that include permissions, owner and group, and last modification date/time, and also include hidden files use: alias ll="ls -al"  Aliases are cumulative, so if the above three aliases are all defined in the order shown, ls, la, and ll will all produce coloured, post-fixed file listings. To always be prompted to confirm file removals use: alias rm="rm -i"  Some things cannot be easily accomplished with aliases and so bash also provides a way of writing functions. One good use for bash functions is creating commands that change directories for you to particular locations without having to type long paths. For example: go_results() { cd /ocean/$USER/MEOPAR/SalishSea/results;
}


creates the go_results command that will cd from wherever you are to the directory where your Salish Sea NEMO model run results are stored.

To ensure that .bashrc is executed when you login via ssh create a file $HOME/.bash_profile with the following lines: if [ -f ~/.bashrc ]; then . ~/.bashrc; fi  ### Loading Modules on HPC Clusters¶ When working on ComputeCanada or Westgrid clusters the module command must be used to load several software components required to compile, run, and work with the results of NEMO. The required modules vary from machine to machine: • On cedar and graham the module load commands you should include in your $HOME/.bashrc are:

module load python/3.7.0

• On orcinus the module load commands you should include in your \$HOME/.bashrc are:

module load python


You can inspect the collection of modules that are loaded with the module list command; for example, on cedar:

module list