When a bash session is started, the bash shell reads the .bashrc file and executes any commands it finds. You may want to edit this file to: automatically add software modules when the shell loads, configure your bash prompt and any other task you deem appropriate.
How do I add software modules to my .bashrc file so that they automatically load when I start a session? You can open/edit your .bashrc file, by starting a session on grace and typing
You should now see something that resembles the image below.
An example of a .bashrc file
Looking at the above image, note the line which starts with "# Add default modules to load here:" You can add the modules which you want to load automatically to this line:
This will load matlab/2012a and stata/11 module automatically
module add matlab/2012a stata/11
A completed example is shown below. Please note that a hash symbol denotes a comment, and as such anything post the hash symbol is ignored. Once you are happy with your edited file, hit:
"Ctrl + x" on your keyboard, then enter "y" and finally hit enter to save the file.
An example of a .bashrc file where "matlab/2012a and stata/11" have been added
Changing ls colours in bash
The default colours associated with file types can be changed. The image below shows a default colour scheme. Follow the instructions below to edit colour properties.
Default colour scheme
Enter the statements below into a terminal, you should now have something that resembles the image below
- cp /etc/DIR_COLORS ~/.dir_colors (Image below)
- vi ~/.dir_colors (Image below)
Editing the file
- Navigate to what you wish to change (Using your keyboard arrows)
- Press the "i" key on your keyboard. This tells the editor to allow you to insert text.
- Update the value you wish to change (e.g. - directory colour from "DIR 01;34" to "DIR 01;33" which changes the directory colour to yellow (Image below)
When you have finished editing the file hit "Esc" then enter ":wq" this saves the file
You will need to restart your session, by logging out and back in again for the changes to be reflected (Image below)
Viewing the colour changes