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 c8139f1b..16380e4c 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