3. Shell - SerbanC/SerbanC.github.io GitHub Wiki
TL:DR: ZSH + Oh-My-ZSH
ZSH Shell
OSX comes installed with a list of shells, of which BASH is the default. I like ZSH more, and it can be made into a more useful shell in some easy steps:
-
Check your ZSH version
zsh --version
-
Confirm ZSH location
which zsh
-
Confirm list of accepted shells
cat /etc/shells
-
Update ZSH with brew
brew install zsh
-
Confirm brew ZSH install location
ls -la /usr/local/bin/zs*
-
Add brew ZSH to list of approved shells
sudo vi /etc/shells
File should look like this:
/bin/bash /bin/csh /bin/ksh /bin/sh /bin/tcsh /bin/zsh /usr/local/bin/zsh <-- the line you're adding
-
Change shell to brew ZSH
chsh -s /usr/local/bin/zsh
-
Restart terminal
-
Confirm using new shell
which zsh
Should return
/usr/local/bin/zsh
orzsh --version
should match
brew info zsh
Oh-my-ZSH
So now you have and are using the latest version of ZSH, and updating will be nicely cared for by Homebrew. Next I'll get Oh-my-ZSH, a framework for ZSH that adds easy theming, bundles of aliases, etc:
- Curl it:
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
- I use a theme that makes use of Powerline, a shell plugin that adds some pretty nice eye-candy. It uses some glyphs that are only available in Powerline Fonts (icons for Git etc.). After some attempts I decided to stick with Menlo for Powerline (not in the above Fonts repo, it's made by someone else), because it's a nice terminal/code editor font. You'll need to download and install it normally in your Font Book. The preview might show some weird/broken glyphs. It's fine.
- In order to properly display it, open iTerm2 and set the font in Preferences > Profile > [Default|Your profile] > Text to 12pt Menlo for Powerline for both Regular and Non-ASCII fonts. I also played around with the horizontal/vertical spacing under each "Change font" to get the best out of it (for me it worked to set both fonts identically to the mark 7 horizontal, and mark about 6.75 vertical, both antialiased).
iTerm 3 beta Note: After switching to iTerm3 beta I noticed that you no longer have to choose two fonts, and instead there's a checkbox (default unchecked) to use a different font for non-ASCII. So in this case, you only need to set the font to Menlo once. Secondly, I didn't neet to tweak the spacing for the font and it looked OK with both vertical and horizontal spacing set to the default 100%.
4. Now you can sudo vim ~/.zshrc
, look for the ZSH_THEME="robbyrussell"
line (/robby
+ Return) and set it to
ZSH_THEME="agnoster"
(make sure your cursor is anywhere inside the word "robbyrussel", type ciw
(Change Inner Word), write agnoster
, hit ESC, then :wq
(Write & Quit))
5. At this point you can also add alias bundles to OMZSH if you want (I leave it alone). By default it adds only Git (which means you get a bunch of shorter Git commands like gst
instead of git status
and such) which you can review by typing alias
.
I recommend ZSH Syntax Highlighting, it makes a nice addition:
brew install zsh-syntax-highlighting
Then, as the post-install instructions also state, add
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
at the END of your .zshrc
file, then either restart your iTerm or re-source the terminal window(s) with
source ~/.zshrc
You can test it at this point by typing brew
. It should be red at bre
and turn green at brew
.