Refactor Plugin loading to be modular
This commit is contained in:
parent
415d335262
commit
da31bc3959
5 changed files with 156 additions and 218 deletions
203
.zgenrc
203
.zgenrc
|
@ -1,203 +0,0 @@
|
||||||
# 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 https://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
|
|
||||||
zgen oh-my-zsh plugins/tmuxinator
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# 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 sources (known/whitelisted) .autoenv.zsh files, as long as you're in the folder (and can 'unsource' on leaving)
|
|
||||||
zgen load Tarrasch/zsh-autoenv
|
|
||||||
|
|
||||||
# radically enhanced cd command, all sorts of options
|
|
||||||
zgen load b4b4r07/enhancd
|
|
||||||
|
|
||||||
# set up nvm, the npm version manager
|
|
||||||
zgen load lukechilds/zsh-nvm
|
|
||||||
|
|
||||||
# Load me last
|
|
||||||
GENCOMPL_FPATH=$HOME/.zsh/complete
|
|
||||||
|
|
||||||
# Save it all to init script.
|
|
||||||
zgen save
|
|
||||||
}
|
|
||||||
|
|
||||||
# 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
|
|
||||||
load-starter-plugin-list
|
|
||||||
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
|
|
55
.zsh.d/20-essential
Normal file
55
.zsh.d/20-essential
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
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
|
||||||
|
|
||||||
|
# Automatically run zgen update and zgen selfupdate every 7 days.
|
||||||
|
zgen load unixorn/autoupdate-zgen
|
||||||
|
|
||||||
|
# Warn you when you run a command that you've set an alias for without
|
||||||
|
# using the alias.
|
||||||
|
zgen load djui/alias-tips
|
||||||
|
|
||||||
|
# Colorize the things if you have grc installed. Well, some of the
|
||||||
|
# things, anyway.
|
||||||
|
zgen load unixorn/warhol.plugin.zsh
|
||||||
|
|
||||||
|
zgen load chrissicool/zsh-256color
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# automatically sources (known/whitelisted) .autoenv.zsh files
|
||||||
|
# as long as you're in the folder (and can optionally 'unsource' on leaving)
|
||||||
|
zgen load Tarrasch/zsh-autoenv
|
||||||
|
|
||||||
|
# radically enhanced cd command, all sorts of options
|
||||||
|
zgen load b4b4r07/enhancd
|
||||||
|
|
||||||
|
# set up nvm, the npm version manager
|
||||||
|
zgen load lukechilds/zsh-nvm
|
||||||
|
|
31
.zsh.d/21-integrations
Normal file
31
.zsh.d/21-integrations
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
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
|
||||||
|
|
||||||
|
# Add git helper scripts.
|
||||||
|
zgen load unixorn/git-extra-commands
|
||||||
|
|
||||||
|
# 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
|
||||||
|
zgen oh-my-zsh plugins/tmuxinator
|
||||||
|
|
||||||
|
# when in a directory with vagrant/docker files can use start, stop, up, down
|
||||||
|
zgen load Cloudstek/zsh-plugin-appup
|
16
.zsh.d/22-autocompletions
Normal file
16
.zsh.d/22-autocompletions
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Tab complete rakefile targets.
|
||||||
|
zgen load unixorn/rake-completion.zshplugin
|
||||||
|
|
||||||
|
# Load me last
|
||||||
|
GENCOMPL_FPATH=$HOME/.zsh/complete
|
69
.zshrc
69
.zshrc
|
@ -1,5 +1,35 @@
|
||||||
#!/bin/zsh
|
#!/bin/zsh
|
||||||
#### ZSHRC - Setting up the Shell
|
|
||||||
|
## DEBUG INFORMATION
|
||||||
|
#
|
||||||
|
# ZSH_SETUP_SHOW_DEBUG="true"
|
||||||
|
#
|
||||||
|
# Uncomment the above line to get debug information during the script setup.
|
||||||
|
print_dbg() {
|
||||||
|
if [ -z $ZSH_SETUP_SHOW_DEBUG ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
printf $@
|
||||||
|
}
|
||||||
|
|
||||||
|
# Clone zgen if you haven't already
|
||||||
|
check_zgen_installation() {
|
||||||
|
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 https://github.com/tarjoilija/zgen.git ./.zgen
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
source $ZGEN_PARENT_DIR/.zgen/zgen.zsh
|
||||||
|
unset ZGEN_PARENT_DIR
|
||||||
|
}
|
||||||
|
|
||||||
|
#### ZSHrc - Setting up the Shell
|
||||||
##
|
##
|
||||||
## Almost all actual setup is being done with the help of individual files
|
## Almost all actual setup is being done with the help of individual files
|
||||||
## in the .zsh.d/ directory. They follow a specific order:
|
## in the .zsh.d/ directory. They follow a specific order:
|
||||||
|
@ -19,18 +49,6 @@
|
||||||
## will be run after numbered ones (in a random order) if you uncomment the
|
## will be run after numbered ones (in a random order) if you uncomment the
|
||||||
## corresponding line below.
|
## corresponding line below.
|
||||||
|
|
||||||
## DEBUG INFORMATION
|
|
||||||
#
|
|
||||||
# ZSH_SETUP_SHOW_DEBUG="true"
|
|
||||||
#
|
|
||||||
# Uncomment the above line to get debug information during the script setup.
|
|
||||||
print_dbg() {
|
|
||||||
if [ -z $ZSH_SETUP_SHOW_DEBUG ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
printf $@
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set ZSH_CONFIG_DIR to default to ~/.zsh.d, or let user override
|
# Set ZSH_CONFIG_DIR to default to ~/.zsh.d, or let user override
|
||||||
# Exit early if no configuration directory has been found
|
# Exit early if no configuration directory has been found
|
||||||
if [ ! -d ${ZSH_CONFIG_DIR:="$HOME/.zsh.d"} ]; then
|
if [ ! -d ${ZSH_CONFIG_DIR:="$HOME/.zsh.d"} ]; then
|
||||||
|
@ -56,9 +74,30 @@ if [ -n "$(/bin/ls $ZSH_CONFIG_DIR/)" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# set up zgen - load external zsh plugins
|
# set up zgen - load external zsh plugins
|
||||||
if [ -f ~/.zgenrc ]; then
|
# If you need to reload your plugins use 'zgen reset' and restart
|
||||||
|
# your shell
|
||||||
|
if [ -n "$(/bin/ls $ZSH_CONFIG_DIR/)" ]; then
|
||||||
print_dbg "Phase 2: Setting up ZGEN\n" #//DEBUG
|
print_dbg "Phase 2: Setting up ZGEN\n" #//DEBUG
|
||||||
source ~/.zgenrc
|
|
||||||
|
check_zgen_installation
|
||||||
|
|
||||||
|
if ! zgen saved; then
|
||||||
|
|
||||||
|
if [ -n "$(/bin/ls $ZSH_CONFIG_DIR/)" ]; then
|
||||||
|
GLOB=($ZSH_CONFIG_DIR/2[0-9]-*)
|
||||||
|
for dotfile in $GLOB; do
|
||||||
|
print_dbg "Phase 3: $dotfile\n" #//DEBUG
|
||||||
|
if [ -r "${dotfile}" ]; then
|
||||||
|
source "${dotfile}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
unset GLOB
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Save it all to init script.
|
||||||
|
zgen save
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load additional settings (30-99) after plugin initialization
|
# Load additional settings (30-99) after plugin initialization
|
||||||
|
|
Loading…
Reference in a new issue