@@ -83,8 +83,14 @@ __FUNC__() {
8383 shift
8484 local dir
8585 if [ "$#" -eq 0 ] && command -v fzf >/dev/null 2>&1; then
86+ local _gtr_porcelain
87+ _gtr_porcelain="$(command git gtr list --porcelain)"
88+ if [ "$(printf '%s\n' "$_gtr_porcelain" | wc -l)" -le 1 ]; then
89+ echo "No worktrees to pick from. Create one with: git gtr new <branch>" >&2
90+ return 0
91+ fi
8692 local _gtr_selection
87- _gtr_selection="$(command git gtr list --porcelain | fzf \
93+ _gtr_selection="$(printf '%s\n' "$_gtr_porcelain" | fzf \
8894 --delimiter=$'\t' \
8995 --with-nth=2 \
9096 --ansi \
@@ -183,8 +189,14 @@ __FUNC__() {
183189 shift
184190 local dir
185191 if [ "$#" -eq 0 ] && command -v fzf >/dev/null 2>&1; then
192+ local _gtr_porcelain
193+ _gtr_porcelain="$(command git gtr list --porcelain)"
194+ if [ "$(printf '%s\n' "$_gtr_porcelain" | wc -l)" -le 1 ]; then
195+ echo "No worktrees to pick from. Create one with: git gtr new <branch>" >&2
196+ return 0
197+ fi
186198 local _gtr_selection
187- _gtr_selection="$(command git gtr list --porcelain | fzf \
199+ _gtr_selection="$(printf '%s\n' "$_gtr_porcelain" | fzf \
188200 --delimiter=$'\t' \
189201 --with-nth=2 \
190202 --ansi \
@@ -287,7 +299,12 @@ function __FUNC__
287299 if test (count $argv) -gt 0; and test "$argv[1]" = "cd"
288300 set -l dir
289301 if test (count $argv) -eq 1; and type -q fzf
290- set -l _gtr_selection (command git gtr list --porcelain | fzf \
302+ set -l _gtr_porcelain (command git gtr list --porcelain)
303+ if test (count $_gtr_porcelain) -le 1
304+ echo "No worktrees to pick from. Create one with: git gtr new <branch>" >&2
305+ return 0
306+ end
307+ set -l _gtr_selection (printf '%s\n' $_gtr_porcelain | fzf \
291308 --delimiter=\t \
292309 --with-nth=2 \
293310 --ansi \
0 commit comments