Skip to content

Instantly share code, notes, and snippets.

@withakay
Created August 19, 2025 14:56
Show Gist options
  • Select an option

  • Save withakay/dec184e9a0a5111b929e6ad8f0399d04 to your computer and use it in GitHub Desktop.

Select an option

Save withakay/dec184e9a0a5111b929e6ad8f0399d04 to your computer and use it in GitHub Desktop.

Revisions

  1. withakay created this gist Aug 19, 2025.
    14 changes: 14 additions & 0 deletions worktree-fzf-cd.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    # include this in your .bash_profile or .zshrc or similar
    # Note: you can't put this in script and call it as `cd` will only affect
    # the subshell the script runs in

    function wtcd () {
    local dir
    dir=$(git wtl --porcelain | grep "^worktree" | awk '{print $2}'| fzf \
    --height=40% \
    --layout=reverse \
    --border \
    --prompt="Select worktree: " \
    --preview="echo {} | awk '{print \$1}' | xargs ls -la 2>/dev/null | head -20" \
    --preview-window=right:50%:wrap) && cd "$dir"
    }