From 93108710e461f2ab8183f319580cfc7153e2a38c Mon Sep 17 00:00:00 2001 From: Tony Miller Date: Tue, 9 Dec 2025 19:59:26 +1000 Subject: [PATCH] add wt - alias to switch between git worktrees --- .zshrc | 30 +++++++++++++++++++ .../VSCodium/User/settings.json | 3 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/.zshrc b/.zshrc index b756672..aed7982 100644 --- a/.zshrc +++ b/.zshrc @@ -133,6 +133,36 @@ alias rm=trash alias gst="git status" alias gwt="git worktree" + +do_cd_worktree() { + # Must be in a git repo + if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + echo "Not in a git repository" + return 1 + fi + + # Get worktree root (handles being in subdirectory of worktree) + local wt_root=$(git rev-parse --show-toplevel 2>/dev/null) + local project_root=$(dirname "$wt_root") + + # If we're in the bare repo root, project_root is parent + if [[ -d "$wt_root/.bare" ]]; then + project_root="$wt_root" + fi + + # Get worktree directories (exclude bare repo) + local selected=$(git worktree list --porcelain | \ + grep '^worktree ' | \ + cut -d' ' -f2- | \ + grep -v '\.bare$' | \ + xargs -I{} basename {} | \ + fzf --height 10% --color=light,hl:196,hl+:196) + + if [[ -n "$selected" ]]; then + cd "${project_root}/${selected}" + fi +} +alias wt="do_cd_worktree" alias gdf="gdifftool" alias fuck="init_thefuck" alias nvm="fnm" diff --git a/Library/Application Support/VSCodium/User/settings.json b/Library/Application Support/VSCodium/User/settings.json index 4f990a6..6b98861 100644 --- a/Library/Application Support/VSCodium/User/settings.json +++ b/Library/Application Support/VSCodium/User/settings.json @@ -8,7 +8,8 @@ "editor.fontWeight": "normal", "window.titleBarStyle": "native", "window.commandCenter": false, - "window.nativeTabs": true, + "window.nativeTabs": false, + "workbench.editor.showTabs": "single", "workbench.editor.showIcons": false, "workbench.layoutControl.enabled": false, "workbench.colorTheme": "MacOS Modern Light - Ventura Xcode Default",