various additions from sim laptop

This commit is contained in:
Alexander Gehrke 2025-05-08 13:55:52 +02:00 committed by Alexander Roso
parent 912a3282c5
commit 21e41141ef
13 changed files with 645 additions and 28 deletions

View file

@ -88,3 +88,16 @@ gclone() {
git clone $url "$@"
}
gwt() {
local current_tree line prefix
typeset -A trees
prefix=$(git rev-parse --show-prefix)
git worktree list --porcelain | while read line; do
if [[ $line = worktree* ]]; then current_tree=${line##worktree }
elif [[ $line = branch* ]]; then trees[${line##branch refs/heads/}]=$current_tree
fi
done
local target=$(for k v in ${(kv)trees}; do echo "$k $v"; done | column -t | fzf ${1:+-q} ${1} -1| awk '{print $2}')
[[ -n $target ]] && cd $target/$prefix
}