Created
May 5, 2023 10:49
-
-
Save fsimonis/e3e76c2bab24d3f3032cbcbd918e5f33 to your computer and use it in GitHub Desktop.
A bash script to change between git worktrees in a terminal using fzf.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
changeworktree() | |
{ | |
WT=$(git worktree list --porcelain | sed -e "/^HEAD/d" -e "/^$/d" -e "s/^worktree //" -e "s/branch refs\/heads\/\(.\+\)/\1/" | paste -d '\t' - - | column -t --output-separator=$'\t' | fzf --ansi | cut -f1 -d' ' ) | |
[ -n "$WT" ] && cd $WT | |
} | |
alias cdgw="changeworktree" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment