Sunday, February 17, 2013

Make your Prompt Pretty and Powerful

I've received a lot of request on what I did to my shell, how to get it to look and behave the way it does, so I'm writing a guide on how to do it.

Requirements

Zsh with Oh-my-zsh config

Powerline Theme

Patched Fonts

GNU Screen (Optional but recommended)

Overview

I'll be writing the step by step guide to getting all of this working. Zsh is required, and most of you probably use bash, but this is not a problem. You can still use bash on your system. You're not replacing bash, just adding zsh. Zsh is mostly reverse compatible with bash (meaning whatever you do in bash will work and work the same in zsh for the most part), but after learning all of what zsh has to offer, you probably will find yourself rarely using bash.

Zsh without a good config is pretty useless. You can go through the kind of long process of creating a zsh config, but I highly recommend using "Oh My Zsh" and then add further customizations to it if you want to. I will give some of my extra configurations I used for it, and you can use them if you'd like.

The patched fonts are supposed to be needed for the theme to display correctly. However, on my machine, I am using Ubuntu Mono Font not patched and only noticed one small glitch that only appears when my pwd is under a git repository directory. You can use Ubuntu Font ( http://font.ubuntu.com ) under any distro or even an entirely different OS. Mono, fixed width fonts are recommended.

GNU Screen adds to shell by making it much more powerful, and also nicer looking with the status and caption bar that you can customize to show different things such as system load all using colors you choose for it. It makes working at the shell much more powerful by giving the ability to have multiple shells running in different "screen windows" (not sure what else to call them), horizontal splits (like the one shown in the screenshot, detaching from a screen, so you can at a later time or date, re-attach the same screen and continue where you left off, monitor for activity or no activity, and have a shared terminal between a friend, coworker or somebody needing help, where both of you can see and type in the same terminal where one user connects through ssh and attaches to your screen session. I won't go into detail on how to do all of that, but I will provide a few links where you can read on how to do all of that.

Or follow the instructions for manually installing oh-my-zsh from the above website.

Once you've done that, you'll need to either logout and log back in for your Linux user or type zsh at the command line to begin using zsh.

Now, to get the prompt that so many have been asking me about, you need the Powerline theme for oh-my-zsh.
If you don't have the git command, use your package manager to install git. This can be done with commands such as apt-get install git or yum install git depending on which Linux distro you use.

Here's the commands you'll need to do in order to get this powerline prompt installed and working.

git clone git://github.com/jeremyFreeAgent/oh-my-zsh-powerline-theme.git
# This next command I do makes the directory a hidden directory.
# I do this to keep my home directory uncluttered.
mv oh-my-zsh-powerline-theme ~/.oh-my-zsh-powerline-theme
cd ~/.oh-my-zsh-powerline-theme
./install_in_omz.sh
# Use gedit, vim, or whatever text editor you want except emacs. To keep it simple,
# I am using nano here.
nano ~/.zshrc
# Now find this line -> ZSH_THEME="robbyrussell"
# And change it to this -> ZSH_THEME="powerline"
# Save and exit from the editor.
source ~/.zshrc

Now your prompt should look similar to mine in the screenshot. Install fonts patched for powerline.

Then set your terminal program to use Ubuntu Mono. If you'd like a different font, just search github for the fonts name powerline. I didn't have to use a patched font for the prompt to display correctly.

See info below for how to update the theme any time you want to update to the latest version.

Terminal Colors

To get the colors the same as I have, open gnome-terminal (or other terminal you use), choose XTerm under "Color Pallet:". Set the text color to be white, bold to be same as text color, and the background to be a grey color with the RGB color code to #3F3F3F

Updating Oh-my-zsh Config and Powerline Theme

Go into the directory containing the powerline theme. If you used the same directory I used in this guide, then:

Keep checking back; Constantly being updated. This Blog aims at the Advanced User as well as the Beginner with little computer knowledge. Beginners, although this is not all for you, a general idea of the concepts are good to have, and I break them down into layman's terms. I also have material specifically for you and guides. Feedback is appreciated, so that I can better help the beginners. Advanced-Users will go straight to the advanced material.

Feed the Fish

Followers

Search This Blog

tons of great information

Subscribe To

About the Blog

This blog is under heavy construction, so keep checking back for new and revised content. This blog is also under a license. Ask me first before reproducing/editing/etc. anything here. If you find this useful, please subscribe. If you appreciate the information and would like me to have more time to work on this, send a donation. Thanks.