ZSH Quickstart Kit
Table of Contents
- Contents of the kit
- Customizing the kit
- Other Resources
This quickstart includes the bullet-train ZSH theme, which requires a Powerline-compatible font in your terminal to display certain status glyphs. Fonts that are Powerline-compatible include many useful glyphs, including the nice branch icon that the theme in this
Here are a few good Powerline-compatible fonts:
- Awesome Terminal Fonts - A family of fonts that includes some nice monospaced Icons.
- Fantasque Awesome Font - A nice monospaced font, patched with Font-Awesome, Octoicons and Powerline-Glyphs.
- Fira Mono - Mozilla's Fira type family.
- Hack - Another Powerline-compatible font designed specifically for source code and terminal usage.
- Input Mono - A family of fonts designed specifically for code. It offers both monospaced and proportional fonts and includes Powerline glyphs.
- Iosevka - Iosevka is an open source slender monospace sans-serif and slab-serif typeface inspired by Pragmata Pro, M+ and PF DIN Mono, designed to be the ideal font for programming.
- Monoid - Monoid is customizable and optimized for coding with bitmap-like sharpness at 15px line-height even on low res displays.
- Mononoki - Mononoki is a typeface by Matthias Tellen, created to enhance code formatting.
- Nerd fonts - A collection of over 20 patched fonts (over 1,700 variations) & the fontforge font patcher python script for Powerline, devicons, and vim-devicons: includes Droid Sans, Meslo, AnonymousPro, ProFont, Inconsolta, and many more.
- Powerline patched font collection - A collection of a dozen or so fonts patched to include Powerline gylphs.
- Victor Mono - Victor Mono is a free programming font with semi-connected cursive italics, symbol ligatures (!=, ->>, =>, ===, <=, >=, ++) and Latin, Cyrillic and Greek characters.
- spacemono - Google's new original monospace display typeface family.
- Download iTerm2 from http://www.iterm2.com. It is considerably nicer than the stock Terminal application that comes with macOS. Please note - there is an RCE flaw in all versions of iTerm 2 before 3.3.6, so update if you're using an affected version.
- Install the current version of Homebrew from http://brew.sh/.
- Install GNU Stow with
brew install stow
- Homebrew has a newer version of
zshthan the one Apple ships, so
brew install zshto install it.
- Switch your shell to
- System Preferences -> Users & Groups.
- Unlock the preferences
- Select your user
- Select advanced options
- Set your login shell to
/usr/local/bin/zshif you decided to use the newer version packaged by
- Install some Powerline-compatible fonts from one of the links in the Fonts section above.
- In iTerm 2, go to Preferences->Profile in your iTerm 2 preferences, then select one of the Powerline-compatible fonts you just installed.
- Make sure you also specify a Powerline-compatible font for non-ASCII in your iTerm 2 preferences or the prompt separators and branch glyphs will show up garbled.
- Switch your shell to
chsh -s /bin/zsh
- Install GNU Stow -
yum install -y stowon Red Hat / CentOS systems,
apt-get -y install stowon Debian / Ubuntu.
- Install the patched font in a valid X font path. Valid font paths can be listed with
mv YourChosenPowerlineFont.otf ~/.fonts
- Update the font cache for the path the font was installed in (root privileges may be needed for updating the font cache for some paths):
fc-cache -vf ~/.fonts/
After installing a Powerline-compatible font, you will also need to configure your terminal emulator to use your selected Powerline-compatible font. The name of the correct font usually ends with for Powerline.
If the Powerline symbols cannot be seen, try closing all instances of the terminal emulator. The X Server may also need to be restarted for the new font to correctly load.
If you still can’t see the new Powerline fonts then double-check that the font has been installed to a valid X font path.
If you get garbled branch glyphs, make sure there isn't a separate font setting for non-ASCII characters in your terminal application that you also need to set to use a Powerline-compatible font. Konsole needs to be set to use UTF-8 encoding, for example.
Set up Zgen and the starter kit
Now that your fonts and default shell have been set up, install zgen and the dotfiles from this starter kit repository.
- Install Zgen
git clone [email protected]:tarjoilija/zgen.git
- Install the starter kit
git clone [email protected]:unixorn/zsh-quickstart-kit.git
- Configure zsh by symlinking the
.zsh-completionsfrom this repo into your
- You can do this with
stow --target=/Users/YourUsername zsh. Replace
/home/YourUsernameif you're on Linux.
- You can do this with
.zsh_functions files included in this kit enable the plugins listed below.
Contents of the kit
The zsh-quickstart-kit configures your ZSH environment so that it includes:
- Automatic periodic updates of both zgen and your plugins
- Cross-session shared history so commands typed in one terminal window can be seen and searched in all your other
zshsessions on the same machine.
- Deduplicating your command history.
- Many more tab completions, courtesy of the zsh-users/zsh-completions repository, and periodic updating to tip of master of that repository so you get updates to the extra tab completions.
- Proper command history search.
- Syntax highlighting at the command line.
- Tab completion of Rakefile targets.
- Enabling oh-my-zsh-compatible plugins and themes (via the zgen framework).
- Various helper functions for interacting with macOS's clipboard, audio volume, Spotlight and Quicklook. For your convenience, these will only load if you are on a macOS machine so you can use the same plugin list on any *NIX system.
- If you've installed iTerm2's shell integration, automatically load it during startup
- chrissicool/zsh-256color - Sets your terminal to 256 colors if available.
- djui/alias-tips - Warns you when you have an alias for the command you just typed, and tells you what it is.
- peterhurford/git-it-on.zsh - Opens your current repo on github, in your current branch.
- RobSis/zsh-completion-generator - Adds a tool to generate ZSH completion functions for programs missing them by parsing their
--helpoutput. Note that this doesn't happen dynamically, you'll have to explicitly run it to create a completion for each command missing one.
- sharat87/pip-app - A set of shell functions to make it easy to install small apps and utilities distributed with
- skx/sysadmin-util - A collection of scripts useful for sysadmins.
- srijanshetty/docker-zsh - Adds completions for
- stackexchange/blackbox - Tom Limoncelli's tool for storing secret information in a repository with gnupg encryption, automatically decrypting as needed.
- supercrabtree/k -
kis a directory lister that also shows git status on files & directories.
- unixorn/autoupdate-zgen - Adds autoupdate (for both
zgenitself, and your plugins) to
- unixorn/bitbucket-git-helpers - Adds
githelper scripts for bitbucket.
- unixorn/git-extra-commands - A collection of extra helper scripts for
- unixorn/jpb.zshplugin - Some of my standard aliases & functions.
- unixorn/rake-completion.zshplugin - Reads the Rakefile in the current directory so you can tab complete the Rakefile targets.
- unixorn/tumult.plugin.zsh - Adds macOS-specific functions and scripts. This plugin only adds itself to your
$PATHif you're running macOS to allow you to use the same plugin list on macOS and other systems.
- zsh-autosuggestions - Adds fish-like autosuggestions to your ZSH sessions.
- zsh-users/zsh-completions - Tab completions for many more applications than come standard with ZSH.
- zsh-users/zsh-history-substring-search - Better history search.
- zsh-users/zsh-syntax-highlighting - Syntax highlighting as you type.
The quickstart kit also uses
zgen to load oh-my-zsh and these plugins:
- brew - only loaded on macOS
- osx - this will only be loaded on macOS
Customizing the kit
Functions and Aliases
.zshrc included in this kit will automatically source any files it finds in
~/.zshrc.d. This makes it easy for you to add extra functions and aliases without having to maintain a separate fork of this repository. The files will be sourced in alphanumeric order after loading all the plugins and I suggest you use a naming scheme of
002-something-else etc to ensure they're loaded in the order you expect.
I like a plugin, but the aliases it installs overwrite other commands or aliases
Make a file in
~/.zshrc.d named something like
999-reset-aliases. Since those are loaded after all the ZSH plugins, you can add lines like
unalias xyzzy to remove an alias named
xyzzy. Once you've cleared all the aliases you don't want, you can add new ones with the names you prefer.
The quickstart kit does an opinionated (i.e. my way) setup of ZSH options and adds some functions and aliases I like on my systems. However,
~/.zshrc.d is processed after the quickstart sets its aliases, functions and ZSH options, so if you don't care for something as set up in the quickstart, you can override the offending item in a shell fragment file there.
The quickstart kit will automatically check for updates every seven days. If you want to change the interval, set
QUICKSTART_KIT_REFRESH_IN_DAYS in a file in
~/.zshrc.d. If you want to disable self updating entirely, add
unset QUICKSTART_KIT_REFRESH_IN_DAYS in a file in
Changing the zgen plugin list
I've included what I think is a good starter set of zsh plugins in this repository. However, everyone has their own preferences for their environment. To make the list easier to customize without having to maintain a separate fork of this kit, if you create a file named
.zshrc from this starter kit will source that instead of running the
load-starter-plugin-list function defined in
~/.zgen-local-plugins is not additive, it will completely replace the kit-provided list of plugins.
I know that it's a pain to create
.zgen-local-plugins from scratch, so to make customizing your plugins easier, I've included a
.zgen-local-plugins-example file at the root of the repository that will install the same plugin list that the kit does by default that you can use as a starting point for your own customizations.
Copy that to your
$HOME/.zgen-local-plugins, change the list and the next time you start a terminal session you'll get your list instead of mine.
The quickstart automatically autoloads zmv. If you want to disable that, create a file named
.zsh-quickstart-no-zmv in your home directory.
If you don't want zgen to load the oh-my-zsh defaults, create
.zsh-quickstart-no-omz in your home directory.
Stow complains with a warning that stowing zsh would cause conflicts
stow --target=/Users/YourUsername zsh in the top level of the repo, and stow printed the following error:
WARNING! stowing zsh would cause conflicts: * existing target is neither a link nor a directory: .zshrc All operations aborted.
Per @jefheaton, this is caused when trying to replace an existing
.zshrc file. He fixed it by closing
~ in Finder so Finder wouldn't create a
.DS_Store file, deleting the existing
.DS_Store, and then removing the old
.zshrc. You may have to rename it first if ZSH is keeping the file open, then deleting it after closing all your Terminal/iTerm 2 windows.
I added a new completion plugin and it isn't working
I've had reports that sometimes you need to reset your completions after adding a new plugin.
rm ~/.zcompdump* compinit
- For a list of other ZSH plugins, completions and themes you might like to use, check out my awesome-zsh-plugins list. It also contains a list of ZSH tutorials.
- Justin Garrison has a good repo that details Mastering ZSH.
Dotfiles in general
dotfiles.github.io/ has a lot of great resources for dotfiles - frameworks for managing them, configurations for editors and other bootstraps with initial configurations to start from.
If you're using vim, spf13 is an excellent starter configuration and plugin collection.