Environment: UNIX/Linux
For macOS users, check out this guide: Deck Out Your Mac Terminal: Part I
In order to customize your shell with aliases, colors, and set a custom prompt, start by adding a .bashrc and a .bash_profile file.
The .bash_profile is executed for login shells and the .bashrc is executed for interactive non-login shells. When you login using a username and password to a server/virtual machine (vm) via ssh or directly on a machine, the .bash_profile is executed to configure the shell before the initial command prompt appears. If you have already logged into the server/vm and open a new terminal window, then the .bashrc is executed before the command prompt appears. The .bashrc is also run when you switch back from another shell (i.e ksh or zsh) into bash.
- On your server / VM, set bash to be your permanent login shell
# set bash as login shell
chsh -s $(which bash)
# check if your shell changed
cat /etc/passwd | grep $(whoami)- Clone the two files and place them into your user home directory
# go into user home
cd ~
# clone repo
git clone https://github.com/zarinlo/custom-bash.git-
Customize your
.bashrcby adding other aliases or changing up the PS1 (Prompt String 1) -
Change permissions on the two files and source the
.bash_profile
# make files executable
chmod u+x .bashrc
chmod u+x .bash_profile
# execute to configure your shell
source .bash_profile-
Exit the shell and log back in to see the changes take affect
-
If you kept the default
.bashrcprovided, you should have the following prompt:
- Bash profile vs bashrc
- Design a prompt using a generator
- Colorize your commands
