Archive for the ‘zsh’ Category

A few zsh tricks I’ve learned so far

September 30, 2012 Leave a comment

It’s the second day since I installed zsh onto my Mac OSX Lion (the exact procedures work on Mountain Lion as well) and I couldn’t help to sharing a few tips that I’ve learned so far:
1. Find all .pdf files under current directory
ls **/*.pdf

2. Go to folder ~/Documents/things/2nd_backup, current folder is ~
cd D/t/2, followed by Tab, autocompletion will change the command into
cd ~/Documents/things/2nd_backup

3.stop a process without running ps
kill, followed by space, tab
If you already know part of the process name, simply, for example
kill ht, Tab (intend to kill running htop process), if htop is the only one that matches ht, command will be automatically converted to
kill pid_of_htop, pretty neat, isn’t it?

4. change default theme from robbyrussell to gentoop The reason I did the switch is because robbyrussell lacks the indication if a user runs “sudo -s” to become root (given the user is given the privilege) and I happened to be a Gentoo fan.
Find the following line in ~/.zshrc and change robbyrussel to gentoo

[UPDATE 10:05PM EDT, 9/30/2012]
I found robbyrussell to be very attractive so I decided to tweak it a bit so it will indicate sudoer status:
vi ~/.oh-my-zsh/themes/robbyrussell.zsh-theme
add “%# ” to the end of PROMPT setting:
PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}%# '
With this change I can easily find out if I am running shell as normal user (%) or root (#), see the screenshot below:

Categories: zsh

Mac OS X Lion zsh installation with brew guide

September 30, 2012 2 comments
brew install zsh
cd $HOME
git clone .oh-my-zsh
sudo chsh -s /usr/local/bin/zsh yourusernamehere
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

Since I am a git nut, I fell in love with zsh right away after I saw the following when I was testing the auto-completion feature of zsh (glad the default zshrc.zsh-template has git enabled in the plugins setting):

The big yellow X means there are changes under current repository, “exp” in red is the name of the current branch. Once I committed the changes, the big yellow X sign disappeared. In other words I don’t even need to type git status to check if current repository is clean – can’t stop loving this feature.


Categories: zsh