diff options
author | Alan Pearce | 2017-04-25 12:44:13 +0200 |
---|---|---|
committer | Alan Pearce | 2017-04-25 12:44:13 +0200 |
commit | e9d22a78a393d2c2e8d4c92c6d39dad8352f49fa (patch) | |
tree | 211eb9b24fd017bcf5968a9b05f501e935db8985 /zsh | |
parent | 7aa006027e6a4d267bdfde0d5a3cf9a3a0377221 (diff) | |
download | nixfiles-e9d22a78a393d2c2e8d4c92c6d39dad8352f49fa.tar.lz nixfiles-e9d22a78a393d2c2e8d4c92c6d39dad8352f49fa.tar.zst nixfiles-e9d22a78a393d2c2e8d4c92c6d39dad8352f49fa.zip |
zsh: Create function & widget to cd into ghq projects
Diffstat (limited to 'zsh')
-rw-r--r-- | zsh/.config/zsh/.zshrc | 20 |
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 |