zsh: widget to cd to any dir in a git repo on C-/
This commit is contained in:
parent
6c91dbbe63
commit
45f4f72eb7
1 changed files with 9 additions and 0 deletions
9
.zshrc
9
.zshrc
|
@ -77,6 +77,14 @@ fre_chpwd() {
|
||||||
typeset -gaU chpwd_functions
|
typeset -gaU chpwd_functions
|
||||||
chpwd_functions+=fre_chpwd
|
chpwd_functions+=fre_chpwd
|
||||||
|
|
||||||
|
_cwd_gitroot() {
|
||||||
|
_gitroot=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
|
||||||
|
_dir=$((echo "$_gitroot" && fd -td . "$_gitroot") | fzf-tmux)
|
||||||
|
[ -n "$_dir" ] && cd $_dir
|
||||||
|
zle && zle redraw-prompt
|
||||||
|
}
|
||||||
|
zle -N _cwd_gitroot
|
||||||
|
|
||||||
## Keybindings
|
## Keybindings
|
||||||
bindkey -e
|
bindkey -e
|
||||||
bindkey '^[[A' history-beginning-search-backward
|
bindkey '^[[A' history-beginning-search-backward
|
||||||
|
@ -84,6 +92,7 @@ bindkey '^[[B' history-beginning-search-forward
|
||||||
bindkey '^P' history-beginning-search-backward
|
bindkey '^P' history-beginning-search-backward
|
||||||
bindkey '^N' history-beginning-search-forward
|
bindkey '^N' history-beginning-search-forward
|
||||||
bindkey '^g' _jump
|
bindkey '^g' _jump
|
||||||
|
bindkey '^_' _cwd_gitroot
|
||||||
|
|
||||||
|
|
||||||
## Gnupg / gpg / ssh / yubikey
|
## Gnupg / gpg / ssh / yubikey
|
||||||
|
|
Loading…
Reference in a new issue