What the $#%@ is the terminal though?
I spend the majority of my time at work on a terminal, mostly because I work by SSH’ing into the high computing cluster at the University. When I have been a teaching assistant for Introduction to Bioinformatics classes, most students are new to using the terminal interface. As a beginning user, it can be pretty intimidating since it’s pretty abstract with no GUI. When I first started out using the terminal, I found it difficult to keep my thoughts organized, especially since I love color coding and organizing things. Well, not all terminals need to be bland and boring. Whether you’re a beginner at using the terminal, or you use it all the time, there’s no reason why you shouldn’t customize it to your liking!
Sorry Windows users, this isn’t relevant for you.
Basic Terminal Appearance
Let’s start with something easy. If you’re using the default Mac terminal, you can do some basic customization with your terminal appearance. Go to Terminal > Preferences > Profiles. There are numerous color schemes on the left, but typically a dark background with light text is easier on the eyes. Choose something you like.
Check out the “Text” and “Window” tabs on the right to customize the look.
Make it transparent
I like having my terminal slightly transparent so I can see things underneath it. Edit the background and lower the opacity from 100% to something lower, depending on how transparent you want it.
Welcome Message
When a bash session terminal opens, a certain file in your home directory called .bashrc
is automatically executed. This is not to be confused with .bash_profile
, which is executed for login shells, like via SSH.
First, go to your home directory.
cd
Next, edit your .bashrc file with your favorite text editor. I use vim.
vim .bashrc
Now, add whatever welcome message you like to this file! Save the file and restart the terminal to see changes.
echo -e "Hi Michelle, how are you doing today"
It’s also fun to add colors. This requires an ANSI terminal. Check out the fun colors, backgrounds, and emphases here Here’s one way to do it:
RED=`tput setaf 1`
WHITEB=`tput setab 7`
RESET=`tput sgr0`
BOLD=`tput smso`
RMBOLD=`tput rmso`
echo -e "${RED}${WHITE}Hi ${BOLD} Michelle ${RMBOLD}, how are you doing today? ${RESET}"
Remove “Last login” message
Everytime you open up a terminal on the Mac, a last login message appears. I really don’t care when the last time I opened up the terminal was, so I got rid of the message by running this command:
touch ~/.hushlogin
To get it back:
rm .hushlogin
Other things to add to .bashrc
Command shortcuts! You can write your own command as a “nickname” for a longer command. I tend to use the command ls -l
to list all files with details, e.g. size, permissions, often. Instead of typing ls -l
, I made a shortcut to type in ll
instead. This shortcut is called an alias.
alias ll='ls -l'
If command line editing gets messed up when you resize terminal window, use this:
shopt -s checkwinsize
I like to add a message to all my start-up files to indicate that the file was executed.
echo -e "${RED}.bashrc invoked${RESET}"
Because I organize my startup files in a certain way, I have some commands in .bash_profile
that I would like to be run when I open up the Mac terminal. Adding this command to your .bashrc will have the .bash_profile
executed when .bashrc
is excuted:
if [ -f ~/.bash_profile ]; then
source ~/.bash_profile
fi
zsh
zsh
, or z shell, is a Unix shell that is faster and more customizable than bash, which is the default for many systems. It includes the features of a bash shell, but has more, including an amazing plugin in my next header. There are a million reasons and advocates of why you should use zsh you can find with a quick Google. If you are a Mac user, zsh is installed by default on the system, but must be updated.
Update zsh
on Mac, assuming homebrew is installed. Note, homebrew is an amazing package manager for macOS that is basically the universal savior.
zsh --version
brew install zsh
If you are using Debian (Linux), install and set it as default login shell:
sudo apt-get install zsh
chsh -s /bin/zsh user
zsh syntax highlighting
There is a miraculous plugin that allows syntax highlighting! It will highlight the current command line as you type, which is a great way to catch syntax errors. You can get this here.
oh-my-zsh
Literally, the most amazing terminal configuration EVER. They call themselves “an open source, community-driven framework for managing your ZSH configuration.” Documentation, code, and more can be found on their GitHub page.
To install via curl:
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
To install via wget:
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
After installation, a ~/.zshrc
file will appear in your home directory to configure oh-my-zsh. This is where you can customize plug-ins and such. Now, the possibilities are endless! The best thing to do first, is to pick a colored theme to make your terminal look all pretty. There are tons of themes here. I am currently using gianu:
Or just lolcat
Get it here.
Parting Words
The terminal doesn’t have to be scary or boring. Configuring the terminal can be a powerful way to make your workflow more efficient, or, just less bland. Try it!
Happy coding!
-Meshell