Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion lib/commands/doctor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,32 @@ 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)"
elif [ -n "$_rc_file" ]; then
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 ""
if [ "$issues" -eq 0 ]; then
echo "Everything looks good!"
Expand Down
23 changes: 20 additions & 3 deletions lib/commands/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <branch>" >&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 \
Expand Down Expand Up @@ -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 <branch>" >&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 \
Expand Down Expand Up @@ -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 <branch>" >&2
return 0
end
set -l _gtr_selection (printf '%s\n' $_gtr_porcelain | fzf \
--delimiter=\t \
--with-nth=2 \
--ansi \
Expand Down