From 405b6476bb58ae4819b4b8281515cf5a4c4250ca Mon Sep 17 00:00:00 2001 From: Tom Elizaga Date: Tue, 24 Feb 2026 13:04:28 -0800 Subject: [PATCH] fix: show helpful error when running `git gtr cd` `cd` only works through the shell function wrapper (`gtr cd`) since subprocesses cannot change the parent shell's directory. Instead of the generic "Unknown command" error, detect `cd` and print setup instructions with the user's shell auto-detected. --- bin/git-gtr | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/git-gtr b/bin/git-gtr index 820f71e..21af41a 100755 --- a/bin/git-gtr +++ b/bin/git-gtr @@ -106,6 +106,14 @@ main() { help|--help|-h) cmd_help "$@" ;; + cd) + local _shell_name + _shell_name="$(basename "${SHELL:-bash}")" + log_error "'cd' requires shell integration (subprocesses cannot change your shell's directory)" + log_info "Set up with: eval \"\$(git gtr init $_shell_name)\"" + log_info "Then use: gtr cd []" + exit 1 + ;; *) log_error "Unknown command: $cmd" echo "Use 'git gtr help' for available commands"