From c9e8636fe505c0c7332ffa32507af6fd28ba09fd Mon Sep 17 00:00:00 2001 From: Tom Elizaga Date: Tue, 24 Feb 2026 13:21:59 -0800 Subject: [PATCH 1/3] fix(ux): improve fzf picker discoverability and empty state - doctor: add shell integration check so users know they need eval "$(git gtr init )" in addition to installing fzf - gtr cd: skip fzf and show guidance when no worktrees exist instead of launching picker with only the main repo listed --- lib/commands/doctor.sh | 17 ++++++++++++++++- lib/commands/init.sh | 23 ++++++++++++++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/lib/commands/doctor.sh b/lib/commands/doctor.sh index 6edf88c..3c288d4 100644 --- a/lib/commands/doctor.sh +++ b/lib/commands/doctor.sh @@ -114,11 +114,26 @@ cmd_doctor() { # Check fzf (optional, for interactive picker) if command -v fzf >/dev/null 2>&1; then - echo "[OK] fzf: $(fzf --version 2>/dev/null | awk '{print $1}') (interactive picker available)" + echo "[OK] fzf: $(fzf --version 2>/dev/null | awk '{print $1}') (interactive picker: gtr cd)" else echo "[i] fzf: not found (install for interactive picker: gtr cd)" fi + # Check shell integration (required for gtr cd) + local _shell_name _rc_file + _shell_name="$(basename "${SHELL:-bash}")" + case "$_shell_name" in + zsh) _rc_file="$HOME/.zshrc" ;; + bash) _rc_file="$HOME/.bashrc" ;; + fish) _rc_file="$HOME/.config/fish/config.fish" ;; + *) _rc_file="" ;; + esac + if [ -n "$_rc_file" ] && [ -f "$_rc_file" ] && grep -q 'git gtr init' "$_rc_file" 2>/dev/null; then + echo "[OK] Shell integration: loaded (gtr cd available)" + else + echo "[i] Shell integration: eval \"\$(git gtr init $_shell_name)\" in ${_rc_file##*/} for gtr cd" + fi + echo "" if [ "$issues" -eq 0 ]; then echo "Everything looks good!" diff --git a/lib/commands/init.sh b/lib/commands/init.sh index d29f02f..daf30c0 100644 --- a/lib/commands/init.sh +++ b/lib/commands/init.sh @@ -83,8 +83,14 @@ __FUNC__() { shift local dir if [ "$#" -eq 0 ] && command -v fzf >/dev/null 2>&1; then + local _gtr_porcelain + _gtr_porcelain="$(command git gtr list --porcelain)" + if [ "$(printf '%s\n' "$_gtr_porcelain" | wc -l)" -le 1 ]; then + echo "No worktrees to pick from. Create one with: git gtr new " >&2 + return 0 + fi local _gtr_selection - _gtr_selection="$(command git gtr list --porcelain | fzf \ + _gtr_selection="$(printf '%s\n' "$_gtr_porcelain" | fzf \ --delimiter=$'\t' \ --with-nth=2 \ --ansi \ @@ -183,8 +189,14 @@ __FUNC__() { shift local dir if [ "$#" -eq 0 ] && command -v fzf >/dev/null 2>&1; then + local _gtr_porcelain + _gtr_porcelain="$(command git gtr list --porcelain)" + if [ "$(printf '%s\n' "$_gtr_porcelain" | wc -l)" -le 1 ]; then + echo "No worktrees to pick from. Create one with: git gtr new " >&2 + return 0 + fi local _gtr_selection - _gtr_selection="$(command git gtr list --porcelain | fzf \ + _gtr_selection="$(printf '%s\n' "$_gtr_porcelain" | fzf \ --delimiter=$'\t' \ --with-nth=2 \ --ansi \ @@ -287,7 +299,12 @@ function __FUNC__ if test (count $argv) -gt 0; and test "$argv[1]" = "cd" set -l dir if test (count $argv) -eq 1; and type -q fzf - set -l _gtr_selection (command git gtr list --porcelain | fzf \ + set -l _gtr_porcelain (command git gtr list --porcelain) + if test (count $_gtr_porcelain) -le 1 + echo "No worktrees to pick from. Create one with: git gtr new " >&2 + return 0 + end + set -l _gtr_selection (printf '%s\n' $_gtr_porcelain | fzf \ --delimiter=\t \ --with-nth=2 \ --ansi \ From f595909edddea2bc398a6d825a73b2d84f8d6b15 Mon Sep 17 00:00:00 2001 From: Tom Elizaga Date: Tue, 24 Feb 2026 13:30:58 -0800 Subject: [PATCH 2/3] fix(doctor): enhance shell integration guidance for fish and other shells - Updated the shell integration message to provide specific instructions for fish users and a general hint for other shells, improving clarity on how to initialize gtr cd. --- lib/commands/doctor.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/commands/doctor.sh b/lib/commands/doctor.sh index 3c288d4..3acc871 100644 --- a/lib/commands/doctor.sh +++ b/lib/commands/doctor.sh @@ -131,7 +131,13 @@ cmd_doctor() { if [ -n "$_rc_file" ] && [ -f "$_rc_file" ] && grep -q 'git gtr init' "$_rc_file" 2>/dev/null; then echo "[OK] Shell integration: loaded (gtr cd available)" else - echo "[i] Shell integration: eval \"\$(git gtr init $_shell_name)\" in ${_rc_file##*/} for gtr cd" + local _init_hint + if [ "$_shell_name" = "fish" ]; then + _init_hint="git gtr init fish | source" + else + _init_hint="eval \"\$(git gtr init $_shell_name)\"" + fi + echo "[i] Shell integration: $_init_hint in ${_rc_file##*/} for gtr cd" fi echo "" From 80ec74e2a727f495b8262896544c6d373f87fc5c Mon Sep 17 00:00:00 2001 From: Tom Elizaga Date: Tue, 24 Feb 2026 13:39:45 -0800 Subject: [PATCH 3/3] fix(doctor): skip shell integration hint for unknown shells --- lib/commands/doctor.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/doctor.sh b/lib/commands/doctor.sh index 3acc871..df749bc 100644 --- a/lib/commands/doctor.sh +++ b/lib/commands/doctor.sh @@ -130,7 +130,7 @@ cmd_doctor() { esac if [ -n "$_rc_file" ] && [ -f "$_rc_file" ] && grep -q 'git gtr init' "$_rc_file" 2>/dev/null; then echo "[OK] Shell integration: loaded (gtr cd available)" - else + elif [ -n "$_rc_file" ]; then local _init_hint if [ "$_shell_name" = "fish" ]; then _init_hint="git gtr init fish | source"