Barbarian Meets Coding Titlebarbarianmeetscoding

WebDev, UX & a Pinch of Fantasy

3 minutes readzsh

Wiki: Zsh, Oh-my-zsh and the shell

Zsh is an alternative unix shell to the more common bash.

File system

$ pwd  # print working directory

$ cd .  # go to current directory
$ cd .. # go to parent directory
$ cd -  # go to last directory
$ cd ~  # go to home directory
$ cd    # go to home directory

$ mkdir something # create directory
$ mkdir something/some/thing -p # creates intermediate directories too


The bang ! in linux shells is normally used to refer to previous commands in the command-line history. In zsh you can use it in much the same way with a small difference, ! in zsh are expanded to whatever they refer. This is useful so that you can be more certain of what you’re actually about to execute. For instance, !! normally refers to the last command in your shell history. In zsh if you type !! followed by space or TAB it will be expanded to that last command:

# We type this command
$ ls -al

# Then this one
$ !! 
# TAB and... It expands to the last command executed
$ ls -al

Here are other useful ! commands:

$ !{char} # expands to last command
$ cat hello.txt
$ !c      # expands to the above

$ !! # expands to last command
$ ls -ll
$ !! # expands to the above

$ !$ # expands to the last commands' arguments

Fuzzy Search in the Command line history and file system

Zsh comes with a really great way to interact with you command line history: forward and backward interactive search. Use C-R to search backwards in your command line history and C-S to do the same thing forwards. It has a limitation though, it only shows one single command a time. fzf is a fuzzy finder that integrates with zsh and enhances it in many different ways. One such way is providing amazing support for fuzzy search in you command line history:

Another is providing fuzzy completion for your file system:

To install fzf follow the instructions in the github repository. If you are using MacOS, you can install it using homebrew:

brew install fzf

# To install useful key bindings and fuzzy completion:
$(brew --prefix)/opt/fzf/install

Interesting Zsh Plugins

  • Syntax highlighting: Provides really nice syntax highlighting right within your zsh terminal
  • Autocompletion suggestions: Provides autosuggestions that you can expand with the right arrow or end. It’s fully customizable.
  • Vi mode: Enables vi mode in Zsh, adds a bunch of key bindings and the curent mode to the prompt.

Cool fonts and color schemes for iTerm2

  • iTerm 2 color schemes. Download a color scheme and within iTerm2 go to profile, colors, import colors, select the file with the color scheme and it will become available in the collection of themes.
  • FiraCode. You’ll need to clone the repo and install the font in TrueType (ttf) format in your mac. Then you’ll be able to enable it within iTerm2.

Great companions for Zsh


Jaime González García

Written by Jaime González García , Dad, Husband, Front-end software engineer, UX designer, amateur pixel artist, tinkerer and master of the arcane arts. You should follow him on Twitter where he shares useful stuff! (and is funny too).Jaime González García