From 9d60ad2e8270e95549bd4bcecd56aa158fbc4629 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 18 May 2017 14:24:54 +0200 Subject: zsh: Use zplugin in place of zplug (except fzf) zplugin seems cleaner than zplug, but it doesn't support github releases, so keep zplug around for now, to load fzf --- zsh/.config/zsh/.zshrc | 56 +++++++++++++++++++++++++++++++++++------------- zsh/.config/zsh/setup.sh | 7 ++++++ 2 files changed, 48 insertions(+), 15 deletions(-) create mode 100755 zsh/.config/zsh/setup.sh (limited to 'zsh') diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 52907de..c8139f1 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -1,23 +1,10 @@ # -*- mode: sh; -*- source $ZPLUG_HOME/init.zsh +source $HOME/.zplugin/bin/zplugin.zsh -zplug "zsh-users/zsh-completions", depth:1, defer:0 zplug "junegunn/fzf-bin", from:gh-r, as:command, rename-to:fzf zplug "junegunn/fzf", as:plugin, use:"shell/*.zsh" zplug "junegunn/fzf", as:command, use:"bin/*" -zplug "caarlos0/zsh-open-pr", as:plugin -zplug "zdharma/fast-syntax-highlighting", as:plugin, defer:2 -zplug "unixorn/tumult.plugin.zsh", as:plugin, if:"[[ $os -eq darwin ]]" -if [[ -n $commands[nix-env] ]] -then - zplug "spwhitt/nix-zsh-completions", as:plugin - fpath=($fpath $ZPLUG_REPOS/spwhitt/nix-zsh-completions) -fi - -zplug "plugins/yarn", from:oh-my-zsh, if:"[[ -n $commands[yarn] ]]" -zplug "lukechilds/zsh-better-npm-completion", if:"[[ -n $commands[npm] ]]" -zplug "hlissner/zsh-autopair" -zplug "${GOPATH:=$HOME/go}/src/github.com/motemen/ghq/zsh/", from:local, if:"[[ -n $commands[ghq] ]]" HISTSIZE=3000 SAVEHIST=10000 @@ -130,9 +117,47 @@ then eval $(ssh-agent) fi -# Then, source plugins and add commands to $PATH +# Plugins + zplug load +zplugin ice blockf +zplugin load "zsh-users/zsh-completions" +zplugin load "hlissner/zsh-autopair" +zplugin load "zdharma/fast-syntax-highlighting" +zplugin load "caarlos0/zsh-open-pr" + + +if [[ $os -eq darwin ]] +then + zplugin load "unixorn/tumult.plugin.zsh" +fi + +if [[ -n $commands[npm] ]] +then + zplugin load "lukechilds/zsh-better-npm-completion" +fi + +if [[ -n $commands[yarn] ]] +then + zplugin snippet "https://github.com/robbyrussell/oh-my-zsh/raw/master/plugins/yarn/yarn.plugin.zsh" +fi + +if [[ -n $commands[nix-env] ]] +then + zplugin load "spwhitt/nix-zsh-completions" +fi + +if [[ -n $commands[ghq] ]] +then + fpath+=("${GOPATH:=$HOME/go}/src/github.com/motemen/ghq/zsh/") +fi + +autoload -Uz compinit +compinit + +zplugin cdreplay -q + # General configuration if [[ -n $commands[hub] ]] @@ -261,3 +286,4 @@ function function eb-active-environment () { } unsetopt flow_control # Let me use ^S and ^Q + diff --git a/zsh/.config/zsh/setup.sh b/zsh/.config/zsh/setup.sh new file mode 100755 index 0000000..61b5441 --- /dev/null +++ b/zsh/.config/zsh/setup.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env zsh + +mkdir $HOME/.zplugin +git clone https://github.com/psprint/zplugin.git $HOME/.zplugin/bin + +zcompile $HOME/.zplugin/bin/zplugin.zsh + -- cgit 1.4.1 From 36b4f758048497cc79ab6855b05f3fd6f1ce6c17 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 18 May 2017 16:02:35 +0200 Subject: zsh: Use anyframe as a fzf wrapper Works around the problem of not being able to use the fzf shell code with zplugin --- zsh/.config/zsh/.zshrc | 45 ++++++++++----------------------------------- 1 file changed, 10 insertions(+), 35 deletions(-) (limited to 'zsh') diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index c8139f1..16380e4 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -2,9 +2,8 @@ source $ZPLUG_HOME/init.zsh source $HOME/.zplugin/bin/zplugin.zsh -zplug "junegunn/fzf-bin", from:gh-r, as:command, rename-to:fzf -zplug "junegunn/fzf", as:plugin, use:"shell/*.zsh" -zplug "junegunn/fzf", as:command, use:"bin/*" +# zplug "junegunn/fzf", as:plugin, use:"shell/*.zsh" +# zplug "junegunn/fzf", as:command, use:"bin/*" HISTSIZE=3000 SAVEHIST=10000 @@ -126,7 +125,7 @@ zplugin load "zsh-users/zsh-completions" zplugin load "hlissner/zsh-autopair" zplugin load "zdharma/fast-syntax-highlighting" zplugin load "caarlos0/zsh-open-pr" - +zplugin load "mollifier/anyframe" if [[ $os -eq darwin ]] then @@ -244,41 +243,17 @@ else precmd_functions+=(update_window_title) fi -if zplug check junegunn/fzf +if [[ -n $commands[fzf] ]] then - bindkey '^T' transpose-chars - _fzf_compgen_path() { - echo "$1" - command find -L "$1" \ - -name .git -prune -o -name .svn -prune -o \( -type d -o -type f -o -type l \) \ - -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' - } - - _fzf_compgen_dir() { - command find -L "$1" \ - -name .git -prune -o -name .svn -prune -o -type d \ - -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' - } - fp () { ghq look $(ghq list | fzf +m) } - cd-project-widget () { - local cmd="ghq list" - setopt localoptions pipefail 2> /dev/null - local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" fzf +m)" - if [[ -z "$dir" ]]; then - zle redisplay - return 0 - fi - cd $(ghq list --full-path | grep "$dir") - local ret=$? - zle reset-prompt - typeset -f zle-line-init >/dev/null && zle zle-line-init - return $ret - } - zle -N cd-project-widget - bindkey '\es' cd-project-widget + + zstyle ":anyframe:selector:fzf:" command "fzf --height 40%" + + bindkey '\es' anyframe-widget-cd-ghq-repository + bindkey '^x^k' anyframe-widget-kill + bindkey '^r' anyframe-widget-put-history fi function function eb-active-environment () { -- cgit 1.4.1 From 7dd1f8511650e690b8b7e7afa5eb473655ce7b18 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 18 May 2017 16:06:52 +0200 Subject: zsh: Remove zplug --- README.org | 15 +++------------ zsh/.config/zsh/.zshenv | 2 -- zsh/.config/zsh/.zshrc | 6 ------ 3 files changed, 3 insertions(+), 20 deletions(-) (limited to 'zsh') diff --git a/README.org b/README.org index 2ed0633..3acd8b2 100644 --- a/README.org +++ b/README.org @@ -4,7 +4,7 @@ I've organised this repository with [[https://www.gnu.org/software/stow/][GNU St [[http://emacs.sexy][Emacs]]. It doesn't use any configuration frameworks, just packages installed -via package managers. For Z shell I use [[https://zplug.sh/][zplug]] and for Emacs I use the +via package managers. For Z shell I use [[https://github.com/zdharma/zplugin][zplugin]] and for Emacs I use the built-in package.el via [[https://github.com/jwiegley/use-package][use-package]]. I've included a wrapper script for =stow= which sets the target @@ -48,21 +48,12 @@ And then to uninstall *** Z Shell -My zsh configuration uses [[https://zplug.sh/][zplug]], so that will need to be installed: +My zsh configuration uses [[https://github.com/zdharma/zplugin][zplugin]]. I've included a setup script: #+BEGIN_SRC sh :exports code -git clone git://github.com/zplug/zplug ~/projects/zplug/ +./zsh/config/zsh/setup.sh #+END_SRC -To install the packages: - -#+BEGIN_SRC sh :exports code -zsh -ic "zplug install" -#+END_SRC - -Note that this will log some errors about a pipe, but that's okay. -zplug is meant to be used in a real interactive shell. - *** Emacs I use org-mode for my Emacs init file. To simplify setup, I created a diff --git a/zsh/.config/zsh/.zshenv b/zsh/.config/zsh/.zshenv index 114e5ce..87276bd 100644 --- a/zsh/.config/zsh/.zshenv +++ b/zsh/.config/zsh/.zshenv @@ -10,8 +10,6 @@ then . $ZDOTDIR/zshenv.private fi - ZPLUG_HOME=${ZPLUG_HOME:-~/projects/github.com/zplug/zplug/} - if [[ -z $SSH_AUTH_SOCK ]] then export SSH_AUTH_SOCK=${XDG_RUNTIME_DIR:-/run/user/$UID}/ssh-agent diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 16380e4..6f112a9 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -1,10 +1,6 @@ # -*- mode: sh; -*- -source $ZPLUG_HOME/init.zsh source $HOME/.zplugin/bin/zplugin.zsh -# zplug "junegunn/fzf", as:plugin, use:"shell/*.zsh" -# zplug "junegunn/fzf", as:command, use:"bin/*" - HISTSIZE=3000 SAVEHIST=10000 HISTFILE=${XDG_CACHE_HOME:=$HOME/.cache}/zsh/history @@ -118,8 +114,6 @@ fi # Plugins -zplug load - zplugin ice blockf zplugin load "zsh-users/zsh-completions" zplugin load "hlissner/zsh-autopair" -- cgit 1.4.1 From 733ed131bb624a41551e738dceb28549b63b491a Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 18 May 2017 16:11:27 +0200 Subject: zsh: Load fzf key-bindings as zplugin snippet --- zsh/.config/zsh/.zshrc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'zsh') diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 6f112a9..409bab9 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -243,11 +243,14 @@ then ghq look $(ghq list | fzf +m) } + zplugin snippet "https://github.com/junegunn/fzf/raw/master/shell/key-bindings.zsh" + + bindkey '^t' transpose-chars + zstyle ":anyframe:selector:fzf:" command "fzf --height 40%" bindkey '\es' anyframe-widget-cd-ghq-repository bindkey '^x^k' anyframe-widget-kill - bindkey '^r' anyframe-widget-put-history fi function function eb-active-environment () { -- cgit 1.4.1 From 49aafb7531cd3d6a5885859b1a56509d45f5e990 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 18 May 2017 16:23:57 +0200 Subject: zsh: Stop anyframe from adding to fpath --- zsh/.config/zsh/.zshrc | 1 + 1 file changed, 1 insertion(+) (limited to 'zsh') diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 409bab9..a0340e1 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -119,6 +119,7 @@ zplugin load "zsh-users/zsh-completions" zplugin load "hlissner/zsh-autopair" zplugin load "zdharma/fast-syntax-highlighting" zplugin load "caarlos0/zsh-open-pr" +zplugin ice blockf zplugin load "mollifier/anyframe" if [[ $os -eq darwin ]] -- cgit 1.4.1 From d0ce60d5743b4d90e154960ab884a486607a4ec6 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 18 May 2017 16:25:21 +0200 Subject: zsh: Fix incorrect function declaration I'm surprised this wasn't a syntax error --- zsh/.config/zsh/.zshrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zsh') diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index a0340e1..1d827a2 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -254,7 +254,7 @@ then bindkey '^x^k' anyframe-widget-kill fi -function function eb-active-environment () { +function eb-active-environment () { aws elasticbeanstalk describe-environments | grep $(dig +short $1 CNAME) | cut -f10 } -- cgit 1.4.1 From 336063f13d39c122fa17ab325117b904b5ed4d82 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 18 May 2017 16:35:35 +0200 Subject: zsh: Load terminal title function from omz directly --- zsh/.config/zsh/.zshrc | 57 ++++---------------------------------------------- 1 file changed, 4 insertions(+), 53 deletions(-) (limited to 'zsh') diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 1d827a2..da25b3d 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -122,6 +122,9 @@ zplugin load "caarlos0/zsh-open-pr" zplugin ice blockf zplugin load "mollifier/anyframe" +zplugin snippet "https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/functions.zsh" +zplugin snippet "https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/termsupport.zsh" + if [[ $os -eq darwin ]] then zplugin load "unixorn/tumult.plugin.zsh" @@ -183,59 +186,7 @@ else setopt prompt_subst setopt prompt_cr PROMPT='%F{blue}%~%f${prompt_pure_username} -%(?.%F{magenta}.%F{red})>%f ' - - ## From https://github.com/robbyrussell/oh-my-zsh/blob/71deb74552d54630d99ae1db3647ebed7b3bc735/lib/termsupport.zsh - - # Keep Apple Terminal.app's current working directory updated - # Based on this answer: http://superuser.com/a/315029 - # With extra fixes to handle multibyte chars and non-UTF-8 locales - - if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then - # Emits the control sequence to notify Terminal.app of the cwd - # Identifies the directory using a file: URI scheme, including - # the host name to disambiguate local vs. remote paths. - function update_terminalapp_cwd() { - emulate -L zsh - - # Percent-encode the pathname. - # Percent-encode the pathname. - local URL_PATH='' - { - # Use LC_CTYPE=C to process text byte-by-byte. - local i ch hexch LC_CTYPE=C - for ((i = 1; i <= ${#PWD}; ++i)); do - ch="$PWD[i]" - if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then - URL_PATH+="$ch" - else - hexch=$(printf "%02X" "'$ch") - URL_PATH+="%$hexch" - fi - done - } - [[ $? != 0 ]] && return 1 - - printf '\e]7;%s\a' "file://$HOST$URL_PATH" - } - - # Use a precmd hook instead of a chpwd hook to avoid contaminating output - precmd_functions+=(update_terminalapp_cwd) - # Run once to get initial cwd set - update_terminalapp_cwd - fi - - function set_window_title { printf '\e]2;%s\a' "$1" } - - function update_window_title { - if [[ -n "$SSH_CONNECTION" || $UID -eq 0 ]] - then - set_window_title "$USER@$HOST" - else - set_window_title "" - fi - } - precmd_functions+=(update_window_title) +%(?.%F{magenta}.%F{red})>%f ' fi if [[ -n $commands[fzf] ]] -- cgit 1.4.1 From b503983d06fb1cdc1577f5abe59988471ea2cc86 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 18 May 2017 16:36:33 +0200 Subject: Remove trailing whitespace --- zsh/.config/zsh/.zshrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zsh') diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index da25b3d..0597013 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -186,7 +186,7 @@ else setopt prompt_subst setopt prompt_cr PROMPT='%F{blue}%~%f${prompt_pure_username} -%(?.%F{magenta}.%F{red})>%f ' +%(?.%F{magenta}.%F{red})>%f ' fi if [[ -n $commands[fzf] ]] -- cgit 1.4.1 From 1b9f08e7bbbeca3dfec7bcb6b8b118dbd6ffdcae Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 19 May 2017 10:06:04 +0200 Subject: zsh: Simplify title in Terminal.app --- zsh/.config/zsh/.zshrc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'zsh') diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 0597013..c8f951b 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -183,6 +183,9 @@ else # show username@host if root, with username in white [[ $UID -eq 0 ]] && prompt_pure_username=' %F{white}%n%f%F{242}@%m%f' + ZSH_THEME_TERM_TAB_TITLE_IDLE="" + ZSH_THEME_TERM_TITLE_IDLE="" + setopt prompt_subst setopt prompt_cr PROMPT='%F{blue}%~%f${prompt_pure_username} -- cgit 1.4.1