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.
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.
First, you need zsh. So use your distros package managers, yum install zsh, apt-get install zsh, emerge -av app-shells/zsh,pacman -S zsh, sbopkg.
Next, zsh is not so good without a good config for it. You need Oh-my-zsh config because of the theme support.
https://github.com/robbyrussell/oh-my-zsh
You can either use the authors install script
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.
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.
There are several plugins you can use with oh-my-zsh.
To this:
Zsh has excellent tab completion. For more information on Zsh, see my other blog post. It has a youtube video as well.
http://linuxinnovations.blogspot.com/2010/10/ultimate-tab-completion.html
Here are the customizations I added to my bottom of my .zshrc. Use them if you'd like:
My .screenrc:
Guide to using GNU Screen:
http://magazine.redhat.com/2007/09/27/a-guide-to-gnu-screen/
Also see the section titled "Sharing a session with others" from that link.
For a really good bash prompt, see the "Crazy Powerful Bash Prompt" here:
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.
Guide
First, you need zsh. So use your distros package managers, yum install zsh, apt-get install zsh, emerge -av app-shells/zsh,
Next, zsh is not so good without a good config for it. You need Oh-my-zsh config because of the theme support.
https://github.com/robbyrussell/oh-my-zsh
You can either use the authors install script
wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
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.
git clone https://github.com/pdf/ubuntu-mono-powerline-ttf.git ~/.fonts/ubuntu-mono-powerline-ttf
fc-cache -fv
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 #3F3F3FUpdating 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:
cd ~/.oh-my-zsh-powerline-theme
git pull
cd ~/.oh-my-zsh
git pull
source ~/.zshrc
Although, by default, the oh-my-zsh configuration will automatically update twice a week.
Tips for Zsh
There are several plugins you can use with oh-my-zsh.
ls .oh-my-zsh/pluginsThat gives you a list of available plugins you can use. These plugins are managed in your .zshrc file. For example, if you wanted to use the colemak and github plugins, you would change this line:
plugins=(git)
To this:
plugins=(git colemak github)
Zsh has excellent tab completion. For more information on Zsh, see my other blog post. It has a youtube video as well.
http://linuxinnovations.blogspot.com/2010/10/ultimate-tab-completion.html
Here are the customizations I added to my bottom of my .zshrc. Use them if you'd like:
########################################
# Customize to your needs...
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/bullshark/bin
# Allow comments when using zsh interactively
setopt interactivecomments
# Turn off annoying autocorrect for dot files
setopt nocorrectall
setopt correct
# Colors with man pages
export PAGER="most -s" # most must be installed
# Gets WAN ip
alias myip='dig myip.opendns.com @resolver1.opendns.com +short'
# Print the first line, column names, of ps output
# Search and output the argument
function psgrep {
if [[ $# -eq 1 && $1 != '-h' && $1 != '--help' ]]
then
ps aux | head -n 1
ps aux | grep -E "$1"
elif [[ $# -eq 2 ]]
then
ps aux | head -n 1
ps aux | grep "$1" "$2"
else
echo "Usage: $0 [GREP_OPTIONS] regexp"
fi
}
# List installed packages in descending order
alias pkglog="grep ' \ install\ ' /var/log/dpkg.log"
More info on GNU screen
My .screenrc:
hardstatus string '%{= bW}%-Lw%{= rW}%50>%n%f* %t%{= bW}%+Lw%< %{= bd}%-=%D %d %M %Y %c:%s%{-}'
caption always "%{= rW} [ %S ] %f %t %? ( %{rY} %u %{rW} ) %?"
term screen-256color
## Default screens
screen 0 weechat-curses
screen 1 # default zsh
screen 2 # default zsh
Guide to using GNU Screen:
http://magazine.redhat.com/2007/09/27/a-guide-to-gnu-screen/
Also see the section titled "Sharing a session with others" from that link.
Extras
For a really good bash prompt, see the "Crazy Powerful Bash Prompt" here:
0 comments:
Post a Comment