From df6164e3aab0e9b12878b308d8e56f1ae07d1289 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Sun, 2 Oct 2016 18:17:25 +1100 Subject: [PATCH] Initial commit, modular zsh config easy to extend with extra behaviours --- home/.zprofile | 1 + home/.zsh/all/functions | 6 +++++ home/.zsh/functions/composer | 5 ++++ home/.zsh/functions/enphp | 2 ++ home/.zsh/functions/unphp | 2 ++ home/.zsh/interactive+login/show_fortune | 2 ++ home/.zsh/interactive/_zplug | 26 ++++++++++++++++++ home/.zsh/interactive/aliases | 17 ++++++++++++ home/.zsh/interactive/bindings | 12 +++++++++ home/.zsh/interactive/fzf | 3 +++ home/.zsh/interactive/history | 4 +++ home/.zsh/interactive/homeshick | 1 + home/.zsh/interactive/iterm2 | 1 + home/.zsh/interactive/options | 5 ++++ home/.zsh/login/editor | 2 ++ home/.zsh/login/fpath | 5 ++++ home/.zsh/login/homeshick | 3 +++ home/.zsh/login/langs | 34 ++++++++++++++++++++++++ home/.zsh/login/path | 17 ++++++++++++ home/.zsh/login/skip | 3 +++ home/.zshenv | 1 + home/.zshrc | 2 ++ 22 files changed, 154 insertions(+) create mode 100644 home/.zprofile create mode 100644 home/.zsh/all/functions create mode 100644 home/.zsh/functions/composer create mode 100644 home/.zsh/functions/enphp create mode 100644 home/.zsh/functions/unphp create mode 100644 home/.zsh/interactive+login/show_fortune create mode 100644 home/.zsh/interactive/_zplug create mode 100644 home/.zsh/interactive/aliases create mode 100644 home/.zsh/interactive/bindings create mode 100644 home/.zsh/interactive/fzf create mode 100644 home/.zsh/interactive/history create mode 120000 home/.zsh/interactive/homeshick create mode 120000 home/.zsh/interactive/iterm2 create mode 100644 home/.zsh/interactive/options create mode 100644 home/.zsh/login/editor create mode 100644 home/.zsh/login/fpath create mode 100644 home/.zsh/login/homeshick create mode 100644 home/.zsh/login/langs create mode 100644 home/.zsh/login/path create mode 100644 home/.zsh/login/skip create mode 100644 home/.zshenv create mode 100644 home/.zshrc diff --git a/home/.zprofile b/home/.zprofile new file mode 100644 index 0000000..1fc9148 --- /dev/null +++ b/home/.zprofile @@ -0,0 +1 @@ +for f in ~/.zsh/login/*; source $f diff --git a/home/.zsh/all/functions b/home/.zsh/all/functions new file mode 100644 index 0000000..566dc7b --- /dev/null +++ b/home/.zsh/all/functions @@ -0,0 +1,6 @@ +#! zsh +# autoloaded functions must be declared in every kind of zsh: they aren't +# inherited in the environment so non-login shells need them, and you'll want +# to call one in a script so non-interactive shells need them. +autoload composer enphp unphp +autoload -Uz zargs zmv diff --git a/home/.zsh/functions/composer b/home/.zsh/functions/composer new file mode 100644 index 0000000..1a4caf8 --- /dev/null +++ b/home/.zsh/functions/composer @@ -0,0 +1,5 @@ +#! zsh +# Composer runs significantly faster if xdebug is unloaded. +local conf="$(php -r 'echo dirname(php_ini_loaded_file());')" +(cd $conf; rsync -ar --delete-after --exclude ext-xdebug.ini conf.d/ conf-without-xdebug.d/) +PHP_INI_SCAN_DIR=$conf/conf-without-xdebug.d php =composer "$@" diff --git a/home/.zsh/functions/enphp b/home/.zsh/functions/enphp new file mode 100644 index 0000000..dc62533 --- /dev/null +++ b/home/.zsh/functions/enphp @@ -0,0 +1,2 @@ +#! zsh +cat $argv | php -r 'echo serialize( json_decode( file_get_contents( "php://stdin" ) ) );' diff --git a/home/.zsh/functions/unphp b/home/.zsh/functions/unphp new file mode 100644 index 0000000..656ba21 --- /dev/null +++ b/home/.zsh/functions/unphp @@ -0,0 +1,2 @@ +#! zsh +cat $argv | php -r 'echo json_encode( unserialize( file_get_contents( "php://stdin" ) ) );' diff --git a/home/.zsh/interactive+login/show_fortune b/home/.zsh/interactive+login/show_fortune new file mode 100644 index 0000000..d760ad1 --- /dev/null +++ b/home/.zsh/interactive+login/show_fortune @@ -0,0 +1,2 @@ +#! zsh +fortune ~/.quotes/quotes | ponysay diff --git a/home/.zsh/interactive/_zplug b/home/.zsh/interactive/_zplug new file mode 100644 index 0000000..baf3b2a --- /dev/null +++ b/home/.zsh/interactive/_zplug @@ -0,0 +1,26 @@ +#! zsh +if [[ ! -f ~/.zplug/repos/zplug/zplug/init.zsh ]]; then + git clone https://github.com/zplug/zplug ~/.zplug/repos/zplug/zplug +fi +source ~/.zplug/repos/zplug/zplug/init.zsh +zplug zplug/zplug +zplug willghatch/zsh-saneopt + +zplug bobthecow/git-flow-completion +zplug mafredri/zsh-async +zplug micha/resty +zplug rupa/z, use:z.sh +zplug sharat87/zsh-vim-mode +zplug sindresorhus/pure +zplug supercrabtree/k +zplug zsh-users/zsh-syntax-highlighting, nice:10 +zplug zsh-users/zsh-completions, nice:11 +zplug zsh-users/zsh-history-substring-search, nice:9 +zplug trapd00r/LS_COLORS, hook-load:apply-trapd00r-colors +apply-trapd00r-colors() { + eval $(dircolors -b $ZPLUG_REPOS/trapd00r/LS_COLORS/LS_COLORS) + zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} +} + +zplug check || zplug install +zplug load diff --git a/home/.zsh/interactive/aliases b/home/.zsh/interactive/aliases new file mode 100644 index 0000000..a1e1028 --- /dev/null +++ b/home/.zsh/interactive/aliases @@ -0,0 +1,17 @@ +#! zsh +alias has_command='whence >/dev/null' +alias ls="ls -F --color=auto" +alias lsl="ls -lh" +alias grep="grep --color=auto" +alias egrep="egrep --color=auto" +alias pseudo="sudo" +if has_command xdg-open; then + alias ]='xdg-open' +else + alias ]='open' +fi + +# make sure ELinks can detect when it's in tmux +alias elinks="STY= elinks" + +has_command hub && alias git=hub diff --git a/home/.zsh/interactive/bindings b/home/.zsh/interactive/bindings new file mode 100644 index 0000000..07f7f72 --- /dev/null +++ b/home/.zsh/interactive/bindings @@ -0,0 +1,12 @@ +#! zsh +bindkey $terminfo[kcbt] reverse-menu-complete + +autoload -Uz bracketed-paste-magic +zle -N bracketed-paste bracketed-paste-magic + +autoload -Uz url-quote-magic +url-quote-magic-with-highlight() { + url-quote-magic + _zsh_highlight +} +zle -N self-insert url-quote-magic-with-highlight diff --git a/home/.zsh/interactive/fzf b/home/.zsh/interactive/fzf new file mode 100644 index 0000000..ba73f00 --- /dev/null +++ b/home/.zsh/interactive/fzf @@ -0,0 +1,3 @@ +#! zsh +export FZF_CTRL_R_OPTS="--sort" +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh diff --git a/home/.zsh/interactive/history b/home/.zsh/interactive/history new file mode 100644 index 0000000..696f55a --- /dev/null +++ b/home/.zsh/interactive/history @@ -0,0 +1,4 @@ +#! zsh +export HISTFILE=~/.zsh/zhistory +export HISTSIZE=50000 +export SAVEHIST=$HISTSIZE diff --git a/home/.zsh/interactive/homeshick b/home/.zsh/interactive/homeshick new file mode 120000 index 0000000..7eef9db --- /dev/null +++ b/home/.zsh/interactive/homeshick @@ -0,0 +1 @@ +../../../../../../.zsh/../.homesick/repos/homeshick/homeshick.sh \ No newline at end of file diff --git a/home/.zsh/interactive/iterm2 b/home/.zsh/interactive/iterm2 new file mode 120000 index 0000000..c4e4e71 --- /dev/null +++ b/home/.zsh/interactive/iterm2 @@ -0,0 +1 @@ +../../../../../../.zsh/../.iterm2_shell_integration.zsh \ No newline at end of file diff --git a/home/.zsh/interactive/options b/home/.zsh/interactive/options new file mode 100644 index 0000000..178051e --- /dev/null +++ b/home/.zsh/interactive/options @@ -0,0 +1,5 @@ +#! zsh +setopt correct + +zstyle ':completion:*' completer _expand _complete _correct _approximate +zstyle ':completion:*' menu select=2 diff --git a/home/.zsh/login/editor b/home/.zsh/login/editor new file mode 100644 index 0000000..ae2d98e --- /dev/null +++ b/home/.zsh/login/editor @@ -0,0 +1,2 @@ +#! zsh +export EDITOR==vim diff --git a/home/.zsh/login/fpath b/home/.zsh/login/fpath new file mode 100644 index 0000000..b4adb0f --- /dev/null +++ b/home/.zsh/login/fpath @@ -0,0 +1,5 @@ +#! zsh +fpath=(~/.zsh/functions ~/.homesick/repos/homeshick/completions $fpath) + +# filter out duplicates, nonexistent directories, and . (the current directory) +fpath=(${(u)^fpath:#.}(N)) diff --git a/home/.zsh/login/homeshick b/home/.zsh/login/homeshick new file mode 100644 index 0000000..d0768a3 --- /dev/null +++ b/home/.zsh/login/homeshick @@ -0,0 +1,3 @@ +#! zsh +path+=(~/.homesick/repos/homeshick/bin) +fpath+=(~/.homesick/repos/homeshick/completions) diff --git a/home/.zsh/login/langs b/home/.zsh/login/langs new file mode 100644 index 0000000..ab600ac --- /dev/null +++ b/home/.zsh/login/langs @@ -0,0 +1,34 @@ +#! zsh + +local newbins=() + +# go +[[ -z $GOPATH ]] && export GOPATH=~/.go +newbins+=(~/.go/bin) + +# haskell +newbins+=(~/.cabal/bin ~/Library/Haskell/bin) + +# ooc +if whence rock >/dev/null; then + export OOC_LIBS=/usr/local/Cellar/rock/0.9.10:~/.ooc + newbins+=(~/.ooc/sam) +fi + +# ruby +newbins+=(~/.gem/ruby/*/bin) + +# perl +export PERL_LOCAL_LIB_ROOT="$HOME/perl5:$PERL_LOCAL_LIB_ROOT" +export PERL_MB_OPT="--install_base '$HOME/perl5'"; +export PERL_MM_OPT="INSTALL_BASE=$HOME/perl5"; +export PERL5LIB="$HOME/perl5/lib/perl5:$HOME/.perllibs:$PERL5LIB"; +newbins+=(~/perl5/bin) + +# php +newbins+=(~/.composer/vendor/bin) + +# python +export -UT PYTHONPATH pythonpath + +path=($newbins $path) diff --git a/home/.zsh/login/path b/home/.zsh/login/path new file mode 100644 index 0000000..b4e9984 --- /dev/null +++ b/home/.zsh/login/path @@ -0,0 +1,17 @@ +#! zsh + +path=(/usr/local/bin $path) +if whence brew >/dev/null; then + path=( + /usr/local/opt/coreutils/libexec/gnubin + /usr/local/sbin + ~/Library/Python/*/bin + $path + ) +fi + +path=(/usr/local/texlive/20*/bin/universal-* $path) +path=(~/bin ~/.bin ~/.local/bin $path) + +# filter out duplicates, nonexistent directories, and . (the current directory) +path=(${(u)^path:#.}(N)) diff --git a/home/.zsh/login/skip b/home/.zsh/login/skip new file mode 100644 index 0000000..bb01985 --- /dev/null +++ b/home/.zsh/login/skip @@ -0,0 +1,3 @@ +#! zsh +skip_global_compinit=1 +skip_path_helper=1 diff --git a/home/.zshenv b/home/.zshenv new file mode 100644 index 0000000..5cd9d0f --- /dev/null +++ b/home/.zshenv @@ -0,0 +1 @@ +for f in ~/.zsh/all/*; source $f diff --git a/home/.zshrc b/home/.zshrc new file mode 100644 index 0000000..cf22121 --- /dev/null +++ b/home/.zshrc @@ -0,0 +1,2 @@ +for f in ~/.zsh/interactive/*; source $f +[[ -o login ]] && for f in ~/.zsh/interactive+login/*; source $f