summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--zsh/.config/zsh/.zshrc20
1 files changed, 20 insertions, 0 deletions
diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc
index 62feedc2..d72307da 100644
--- a/zsh/.config/zsh/.zshrc
+++ b/zsh/.config/zsh/.zshrc
@@ -234,6 +234,26 @@ then
             -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
 fi
 
 unsetopt flow_control       # Let me use ^S and ^Q