Exercise 1.2: Making an rc file


Having a .bashrc or .zshrc file allows you to configure your shell how you like.

a) If you are using Linux or macOS, open a terminal and type

echo $SHELL

This will tell you if you are using a Bash shell or Zsh, which will tell you which kind of rc file to set up in the next part of the exercise. If you are using Windows, you will create a .bashrc file.

b) Create a .bashrc or .zshrc file in your home directory. If you already have one, open it up for editing using Jupyter’s text editor.

c) It is often useful to alias functions to other functions. For example, I am always worried I will accidentally delete things by accident. I therefore have the following line in my .zshrc file.

alias rm="rm -i"

You should create aliases for commands like ls based on the flags you like to always use. Do the same for rm and mv (I use the -i flag with these). To figure out what flags are available, you can look at the man pages. Asking Google will usually give you the information you need on flags.

If you like, you can use my .bashrc file, available in ~/git/bootcamp/misc/jb_bashrc, or my .zshrc file, available in ~/git/bootcamp/misc/jb_zshrc.

d) Depending on your operating system, if you are using Bash, your ~/.bashrc file may or may not be properly loaded upon opening a new bash shell. You may, e.g. for new macOS versions, need to explicitly source your .bashrc file in your ~/.bash_profile file. Therefore, you should add the following to the bottom of your ~/.bash_profile file.

if [ -f $HOME/.bashrc ]; then
    . $HOME/.bashrc
fi