dotfiles/.zgenrc

211 lines
6.6 KiB
Text
Raw Normal View History

2019-02-04 02:32:45 +00:00
# Clone zgen if you haven't already
if [[ -z "$ZGEN_PARENT_DIR" ]]; then
ZGEN_PARENT_DIR=$HOME
fi
if [[ ! -f $ZGEN_PARENT_DIR/.zgen/zgen.zsh ]]; then
if [[ ! -d "$ZGEN_PARENT_DIR" ]]; then
mkdir -p "$ZGEN_PARENT_DIR"
fi
pushd $ZGEN_PARENT_DIR
git clone git@github.com:tarjoilija/zgen.git ./.zgen
popd
fi
source $ZGEN_PARENT_DIR/.zgen/zgen.zsh
unset ZGEN_PARENT_DIR
load-starter-plugin-list() {
echo "Creating a zgen save"
ZGEN_LOADED=()
ZGEN_COMPLETIONS=()
zgen oh-my-zsh
# If you want to customize your plugin list, create a file named
# .zgen-local-plugins in your home directory. That file will be sourced
# during startup *instead* of running this load-starter-plugin-list function,
# so make sure to include everything from this function that you want to keep.
# If zsh-syntax-highlighting is bundled after zsh-history-substring-search,
# they break, so get the order right.
zgen load zdharma/fast-syntax-highlighting
zgen load zsh-users/zsh-history-substring-search
# Set keystrokes for substring searching
zmodload zsh/terminfo
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down
# Tab complete rakefile targets.
zgen load unixorn/rake-completion.zshplugin
# Automatically run zgen update and zgen selfupdate every 7 days.
zgen load unixorn/autoupdate-zgen
# Add my collection of miscellaneous utility functions.
#zgen load unixorn/jpb.zshplugin
# Colorize the things if you have grc installed. Well, some of the
# things, anyway.
zgen load unixorn/warhol.plugin.zsh
# Warn you when you run a command that you've set an alias for without
# using the alias.
zgen load djui/alias-tips
# Add my collection of git helper scripts.
zgen load unixorn/git-extra-commands
# Add my bitbucket git helpers plugin.
#zgen load unixorn/bitbucket-git-helpers.plugin.zsh
# A collection of scripts that might be useful to sysadmins.
# zgen load skx/sysadmin-util
# Adds aliases to open your current repo & branch on github.
zgen load peterhurford/git-it-on.zsh
# Tom Limoncelli's tooling for storing private information (keys, etc)
# in a repository securely by encrypting them with gnupg.
zgen load StackExchange/blackbox
# Load some oh-my-zsh plugins
zgen oh-my-zsh plugins/pip
zgen oh-my-zsh plugins/sudo
zgen oh-my-zsh plugins/aws
zgen oh-my-zsh plugins/chruby
zgen oh-my-zsh plugins/colored-man-pages
zgen oh-my-zsh plugins/git
zgen oh-my-zsh plugins/github
zgen oh-my-zsh plugins/python
zgen oh-my-zsh plugins/rsync
zgen oh-my-zsh plugins/screen
zgen oh-my-zsh plugins/vagrant
zgen oh-my-zsh plugins/autojump
zgen oh-my-zsh plugins/tmux
2019-02-04 14:27:49 +00:00
zgen oh-my-zsh plugins/tmuxinator
2019-02-04 02:32:45 +00:00
if [ $(uname -a | grep -ci Darwin) = 1 ]; then
# Load macOS-specific plugins
zgen oh-my-zsh plugins/brew
zgen oh-my-zsh plugins/osx
fi
# A set of shell functions to make it easy to install small apps and
# utilities distributed with pip.
zgen load sharat87/pip-app
zgen load chrissicool/zsh-256color
# Load more completion files for zsh from the zsh-lovers github repo.
zgen load zsh-users/zsh-completions src
# Docker completion
zgen load srijanshetty/docker-zsh
# Load me last
GENCOMPL_FPATH=$HOME/.zsh/complete
# Very cool plugin that generates zsh completion functions for commands
# if they have getopt-style help text. It doesn't generate them on the fly,
# you'll have to explicitly generate a completion, but it's still quite cool.
zgen load RobSis/zsh-completion-generator
# Add Fish-like autosuggestions to your ZSH.
zgen load zsh-users/zsh-autosuggestions
# k is a zsh script / plugin to make directory listings more readable,
# adding a bit of color and some git status information on files and
# directories.
zgen load supercrabtree/k
# Bullet train prompt setup.
zgen load bhilburn/powerlevel9k powerlevel9k
# when in a directory with vagrant/docker files can use start, stop, up, down
zgen load Cloudstek/zsh-plugin-appup
# automatically add .env contents to environment vars, as long as you're in the folder
zgen load zpm-zsh/autoenv
# radically enhanced cd command, all sorts of options
zgen load b4b4r07/enhancd
zgen load lukechilds/zsh-nvm
# Save it all to init script.
zgen save
}
setup-zgen-repos() {
if [[ -f ~/.zgen-local-plugins ]]; then
source ~/.zgen-local-plugins
else
load-starter-plugin-list
fi
}
# This comes from https://stackoverflow.com/questions/17878684/best-way-to-get-file-modified-time-in-seconds
# This works on both Linux with GNU fileutils and macOS with BSD stat.
# Naturally BSD/macOS and Linux can't share the same options to stat.
if [[ $(uname | grep -ci -e Darwin -e BSD) = 1 ]]; then
# macOS version.
get_file_modification_time() {
modified_time=$(stat -f %m "$1" 2> /dev/null) || modified_time=0
echo "${modified_time}"
}
elif [[ $(uname | grep -ci Linux) = 1 ]]; then
# Linux version.
get_file_modification_time() {
modified_time=$(stat -c %Y "$1" 2> /dev/null) || modified_time=0
echo "${modified_time}"
}
fi
# check if there's an init.zsh file for zgen and generate one if not.
if ! zgen saved; then
setup-zgen-repos
fi
# Our installation instructions get the user to make a symlink
# from ~/.zgen-setup to wherever they checked out the zsh-quickstart-kit
# repository.
#
# Unfortunately, stat will return the modification time of the
# symlink instead of the target file, so construct a full path to hand off
# to stat so it returns the modification time of the actual .zgen-setup file.
if [[ -f ~/.zgen-setup ]]; then
REAL_ZGEN_SETUP=~/.zgen-setup
fi
if [[ -L ~/.zgen-setup ]]; then
REAL_ZGEN_SETUP="$(readlink ~/.zgen-setup)"
fi
# If you don't want my standard starter set of plugins, create a file named
# .zgen-local-plugins and add your zgen load commands there. Don't forget to
# run `zgen save` at the end of your .zgen-local-plugins file.
#
# Warning: .zgen-local-plugins REPLACES the starter list setup, it doesn't
# add to it.
#
# Use readlink in case the user is symlinking from another repo checkout, so
# they can use a personal dotfiles repository cleanly.
if [[ -f ~/.zgen-local-plugins ]]; then
REAL_ZGEN_SETUP=~/.zgen-local-plugins
fi
if [[ -L ~/.zgen-local-plugins ]]; then
REAL_ZGEN_SETUP="${HOME}/$(readlink ~/.zgen-local-plugins)"
fi
# If .zgen-setup is newer than init.zsh, regenerate init.zsh
if [ $(get_file_modification_time ${REAL_ZGEN_SETUP}) -gt $(get_file_modification_time ~/.zgen/init.zsh) ]; then
echo "$(basename ${REAL_ZGEN_SETUP}) updated; creating a new init.zsh from plugin list in ${REAL_ZGEN_SETUP}"
setup-zgen-repos
fi
unset REAL_ZGEN_SETUP