A few zsh tricks I’ve learned so far
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
ZSH_THEME=”robbyrussell”
[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: