From e9d22a78a393d2c2e8d4c92c6d39dad8352f49fa Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Tue, 25 Apr 2017 12:44:13 +0200 Subject: zsh: Create function & widget to cd into ghq projects --- zsh/.config/zsh/.zshrc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'zsh') diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 62feedc..d72307d 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 -- cgit 1.4.1