The ZSH Shell

What is the Zsh shell?
It’s just a terminal.

Why use Zsh?
This is a really cool terminal.

There are many Pros to why you should use the Zsh shell. Here’s my sales pitch to using it.

  • Pros
    • lower case completion** document Document both work with tab
    • history based on what you have already typed in prompt – if you type c and hit up arrow, will only show you commands with c
    • Better than man page ls - tab see all flags!

Make directory and takes you inside it!

$ take

Powerline fonts

  • Add powerline fonts
    fonts

This is what the plain Terminal looks like:
Terminal

This is what Zsh looks like:
Zsh

Just based on that alone is cause to use Zsh. But there are tons of other things Zsh give you ability to do. If that doesn’t pull you over to the dark side, watch these *free Videos by Wes Bos.

  • Thanks for the tip Sean!

Oh-my-zsh

Read more about oh-my-zsh

Great people got together to make working with zsh great.

Install oh-my-zsh

$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

See hidden files

When working with zsh you will want to see hidden files. Just add the code below to get it to work.

source: show hidden files on mac

$ defaults write com.apple.finder AppleShowAllFiles YES

Press return and relaunch finder (hover over finder icon on dashboard and hold down option key, this will let you relaunch finder)
* You can also choose from dropdown

Now when you open it up you will see hidden files like .zshrc and .oh-my-zsh

Choose a theme

Lots to choose from.

Here’s one theme:

cobalt2

https://github.com/wesbos/Cobalt2-iterm

~/.zshrc

This is your profile config file for zsh. The bash shell has the .bash_profile file. zsh has the .zshrc file.

It is located in the user directory (~/.zshrc)

Open that file in Sublime Text and change the ZSH_THEME.

ZSH_THEME="agnoster"

Take the shorter PATH

One of the first things that bugged me is the long file paths in the Zsh. It made working in zsh problematic. There is an easy solution where you just show the parent and grandparent directorires only.

This is the function that creates the path you see output in the zsh

prompt_dir() {
  prompt_segment blue black '%2/'
  #echo $(pwd | sed -e "s,^$HOME,~," | sed "s@\(.\)[^/]*/@\1/@g")
  #echo $(pwd | sed -e "s,^$HOME,~,")
}

Since I have the number 2, I will only ever see 2 directories

Something that looks like this:
long zsh path

Can be made to look like this:
short zsh path

What is my Path?

If you ever need to find out the full path, just type $ pwd.

What’s my current theme in zsh?

Open your .zshrc file

ZSH_THEME="cobalt2"

Where are my Zsh themes located?

Open up that theme by going to your themes folder

$ cd ~/.oh-my-zsh/themes/

I’m using the cobalt2 theme so I opened that theme up and commented out the existing code (comments are made using #)

Leave a Reply

Your email address will not be published. Required fields are marked *