aboutsummaryrefslogtreecommitdiff

ZSH Presentation

This was part of an internal presentation I gave at parsely on how to build a minimal setup for zsh. You can clone this repo to ~/.dotfiles and use it as a skeleton to start your own minimal zsh/dotfile structure.

Overwhelming list of plugin stuff

https://github.com/unixorn/awesome-zsh-plugins

There is so much to read but I would mostly just skim plugins for things you need.

https://github.com/unixorn/awesome-zsh-plugins#plugins

Fun example I found while browsing plugins

https://github.com/mattberther/zsh-pyenv

Source: http://brandon.invergo.net/news/2012-05-26-using-gnu-stow-to-manage-your-dotfiles.html?round=two

Stow mocks the directory stucture of the .dotfiles to understand where files should go. So instead of doing say:

ln -s /path/to/my/source/file.txt /path/to/symlink.txt

You create the directory structure with actual folders and stow can use that structure to determine where to place the files given a root directory. It will complain if files already exist so you won't overwrite them. To install the dotfiles you can simply:

cd stow
./install

Functions and Aliases

I only split up my main config and another file that contains my functions and aliases. I've included a filtered version of my aliases to give ideas, but there is a lot cruft in there.

Essential Tools: - fzf (https://github.com/junegunn/fzf) - gh (github cli https://cli.github.com/) - exa (pretty ls https://github.com/ogham/exa)

Zplug

zplug is a zsh plugin manager. Add the repos you want in your ~/.zshrc and then when you start a new shell you'll be prompted to install the new plugins. Supports oh-my-zsh plugins.

Autocompletes

zsh uses a variable called fpath to determine where to find autocomplete files. Autocomplete files are prefixed with an underscore and then the command name. For example, to find the autocompletes for docker, zsh would search the fpath variable for a file called _docker. You can write your own autocompletes for things. Defining an alias in your zsh will let the alias pick up the autocompletes for the original commands but if you write a function it will not:

# gss will pick up the tab completion for git stash
alias gs="git stash"
# this will not
gs() {
    git stash
}

You can use the compdef function to assign the autocompletes of one command to another. Example in zshrc

You can also write your own completions if you know a simple bash command to get the list of options you'd like to be presented with.