Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # git worktree移動
- function cdworktree() {
- # カレントディレクトリがGitリポジトリ上かどうか
- git rev-parse &>/dev/null
- if [ $? -ne 0 ]; then
- echo fatal: Not a git repository.
- return
- fi
- local selectedWorkTreeDir=`git worktree list | fzf | awk '{print $1}'`
- if [ "$selectedWorkTreeDir" = "" ]; then
- # Ctrl-C.
- return
- fi
- BUFFER+="cd $selectedWorkTreeDir"
- zle accept-line
- }
- zle -N cdworktree
- bindkey '^w' cdworktree
Add Comment
Please, Sign In to add comment