Home > zsh > A few zsh tricks I’ve learned so far

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

[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
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: