I frequently use the command line because of its speed and am using ohmyzsh to make the experience more valuable and enjoyable. I configure ohmyzsh to use the powerlevel9k theme which provides lots of useful information as well as looking fancy.
We are more connected to the work we do if its an enjoyable experience.
Read on for details on how to configure Ubuntu with zsh, ohmyzsh and powerlevel9k theme.
Using the command line is a powerful and quick way of doing many developer tasks. The command line shell) for Linux & MacOSX is a whole world apart from the very basic experience of DOS. Zsh (Z Shell) makes the Linux & MacOSX shell experience even better.
I learnt to use the command line with bash, the default Linux shell. Although as soon as you play with zsh for a few minutes, you quickly get hooked. zsh gives you lots of features, including:
auto-completion on steroids
command relative completions
navigable completions list
amazingly fast completions
auto corrections for when your fingers slip
custom prompts, a right hand prompt and themes
shared history over all terminals
history sub-string search
You can add libraries to bash and configure it to do these things as well, although I havent seen an projects to help you quickly do so.
This is a popular project that provides an out of the box zsh setup and its really easy to use. However, something is making it a little slow when I tried it on the MacBook Pro and Linux. Comments around this project suggest its written in more of a bash way than zsh, so that may be the reason for a performance slow down.
After a few days I decided to remove oh-my-zsh and try an alternative project.
Check that the links have all been created successfully. Type the command ls -la and you should see the following in your terminal (although possibly without colour)
Set zsh as the default shell
Exit the zsh session or close the terminal and start a new terminal.
Set zsh as the default shell using the chsh (change shell) command:
chsh -s /usr/bin/zsh
The default shell can also be defined in the Gnome Terminal configure, setting zsh to run a custom command. which zsh command will show the full path to zsh.
When opening a new terminal window or tab, the command line should run Zsh by default.
Showing Git branch by switching on zsh modules
Several of the prezto zsh modules are switched on by default, however Git is not one of them. If you want to see the current branch you are working on in Git then add the git module to the zprezto configuration.
Edit the file ~/.zprezto
Find the section in the file that defined modules to load and add a line with the git module. Here is what that section would look like once you have edited it.
# Set the Prezto modules to load (browse modules).
# The order matters.
zstyle ':prezto:load' pmodule \
Creating my own prezto theme
The default sorin them is okay, but takes up a bit much room on the prompt than I like.
I created my own theme as a slight variation from the default sorin theme. I removed >>> characters used to separate the prompt from commands as they seemed largely unnecessary. As I only use git then I didnt feel the need to specify the version control tool used (eg. git, mercurial). Finally, I changed the colours round a little.
I kept the right hand prompt as part of my theme. Its a quick way to show the status of any changes in your local git repository.
The prompt shows the current folder name, with any parent folders abbreviated to their initial. The path up to and including the home folder is represented by ~.
When you enter a folder managed by git, then the right hand prompt kicks in and shows icons representing the current git status. Whilst in the folder you can see if you have changes that untracked, deleted or stage. You can easily tell if you are behind or ahead of the default remote repository. You can also see if you have some changes stashed away.
Whist oh-my-zsh is really simple to use, the Prezto project seems to have maintainters with greater experience of zsh.
On Ubuntu I am using prezto and although it is a bit more involved to understand at first, it runs really really fast. The only thing I wanted to change with prezto was the theme, so not really that much to learn.
Everything that I was doing with oh-my-zsh seems to work in Prezto without adding in extra plugins to the Zsh configuration.
So although oh-my-zsh is a great project, I’d recommend using Prezto to have a great Zsh experience. Take a look at my dotfiles on github (dot-files-ubuntu or dot-files-macosx) to see how I created a custom theme.