-
Notifications
You must be signed in to change notification settings - Fork 90
fix: resolve gtr/coreutils naming conflict and add cd completions #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,118 @@ | ||
| #!/usr/bin/env bash | ||
| # git-gtr - Git worktree runner (git subcommand wrapper) | ||
| # Allows running as: git gtr <command> | ||
|
|
||
| # Find this script's real location (resolve symlinks) | ||
| SRC="${BASH_SOURCE[0]}" | ||
| while [ -h "$SRC" ]; do | ||
| DIR="$(cd -P "$(dirname "$SRC")" && pwd)" | ||
| SRC="$(readlink "$SRC")" | ||
| [[ $SRC != /* ]] && SRC="$DIR/$SRC" | ||
| # git-gtr - Git worktree runner | ||
| # Portable, cross-platform git worktree management | ||
| # Invoked as: git gtr <command> (git subcommand via PATH discovery) | ||
|
|
||
| set -e | ||
|
|
||
| # Debug: show file:line:function on set -e failures | ||
| if [ -n "${GTR_DEBUG:-}" ]; then | ||
| trap 'printf "ERROR at %s:%s in %s()\n" "${BASH_SOURCE[0]}" "$LINENO" "${FUNCNAME[0]:-main}" >&2' ERR | ||
| fi | ||
|
|
||
| # Version | ||
| GTR_VERSION="2.3.0" | ||
|
|
||
| # Find the script directory (resolve symlinks; allow env override) | ||
| resolve_script_dir() { | ||
| local src="${BASH_SOURCE[0]}" | ||
| while [ -h "$src" ]; do | ||
| local dir | ||
| dir="$(cd -P "$(dirname "$src")" && pwd)" | ||
| src="$(readlink "$src")" | ||
| [[ $src != /* ]] && src="$dir/$src" | ||
| done | ||
| cd -P "$(dirname "$src")/.." && pwd | ||
| } | ||
| : "${GTR_DIR:=$(resolve_script_dir)}" | ||
|
|
||
| # Source library files | ||
| . "$GTR_DIR/lib/ui.sh" | ||
| . "$GTR_DIR/lib/args.sh" | ||
| . "$GTR_DIR/lib/config.sh" | ||
| _ui_apply_color_config | ||
| . "$GTR_DIR/lib/platform.sh" | ||
| . "$GTR_DIR/lib/core.sh" | ||
| . "$GTR_DIR/lib/copy.sh" | ||
| . "$GTR_DIR/lib/hooks.sh" | ||
| . "$GTR_DIR/lib/provider.sh" | ||
| . "$GTR_DIR/lib/adapters.sh" | ||
| . "$GTR_DIR/lib/launch.sh" | ||
|
|
||
| # Source command handlers | ||
| for _cmd_file in "$GTR_DIR"/lib/commands/*.sh; do | ||
| # shellcheck disable=SC1090 | ||
| . "$_cmd_file" | ||
| done | ||
| SCRIPT_DIR="$(cd -P "$(dirname "$SRC")" && pwd)" | ||
| unset _cmd_file | ||
|
|
||
| # Main dispatcher | ||
| main() { | ||
| local cmd="${1:-help}" | ||
| shift 2>/dev/null || true | ||
|
|
||
| # Set for per-command help (used by show_command_help in ui.sh) | ||
| _GTR_CURRENT_COMMAND="$cmd" | ||
|
|
||
| case "$cmd" in | ||
| new) | ||
| cmd_create "$@" | ||
| ;; | ||
| rm) | ||
| cmd_remove "$@" | ||
| ;; | ||
| mv|rename) | ||
| cmd_rename "$@" | ||
| ;; | ||
| go) | ||
| cmd_go "$@" | ||
| ;; | ||
| run) | ||
| cmd_run "$@" | ||
| ;; | ||
| editor) | ||
| cmd_editor "$@" | ||
| ;; | ||
| ai) | ||
| cmd_ai "$@" | ||
| ;; | ||
| copy) | ||
| cmd_copy "$@" | ||
| ;; | ||
| ls|list) | ||
| cmd_list "$@" | ||
| ;; | ||
| clean) | ||
| cmd_clean "$@" | ||
| ;; | ||
| doctor) | ||
| cmd_doctor "$@" | ||
| ;; | ||
| adapter|adapters) | ||
| cmd_adapter "$@" | ||
| ;; | ||
| config) | ||
| cmd_config "$@" | ||
| ;; | ||
| completion) | ||
| cmd_completion "$@" | ||
| ;; | ||
| init) | ||
| cmd_init "$@" | ||
| ;; | ||
| version|--version|-v) | ||
| echo "git gtr version $GTR_VERSION" | ||
| ;; | ||
| help|--help|-h) | ||
| cmd_help "$@" | ||
| ;; | ||
| *) | ||
| log_error "Unknown command: $cmd" | ||
| echo "Use 'git gtr help' for available commands" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| } | ||
|
|
||
| # Execute the main gtr script | ||
| exec "$SCRIPT_DIR/gtr" "$@" | ||
| # Run main | ||
| main "$@" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,117 +1,15 @@ | ||
| #!/usr/bin/env bash | ||
| # gtr - Git worktree runner | ||
| # Portable, cross-platform git worktree management | ||
|
|
||
| set -e | ||
|
|
||
| # Debug: show file:line:function on set -e failures | ||
| if [ -n "${GTR_DEBUG:-}" ]; then | ||
| trap 'printf "ERROR at %s:%s in %s()\n" "${BASH_SOURCE[0]}" "$LINENO" "${FUNCNAME[0]:-main}" >&2' ERR | ||
| fi | ||
|
|
||
| # Version | ||
| GTR_VERSION="2.3.0" | ||
|
|
||
| # Find the script directory (resolve symlinks; allow env override) | ||
| resolve_script_dir() { | ||
| local src="${BASH_SOURCE[0]}" | ||
| while [ -h "$src" ]; do | ||
| local dir | ||
| dir="$(cd -P "$(dirname "$src")" && pwd)" | ||
| src="$(readlink "$src")" | ||
| [[ $src != /* ]] && src="$dir/$src" | ||
| done | ||
| cd -P "$(dirname "$src")/.." && pwd | ||
| } | ||
| : "${GTR_DIR:=$(resolve_script_dir)}" | ||
|
|
||
| # Source library files | ||
| . "$GTR_DIR/lib/ui.sh" | ||
| . "$GTR_DIR/lib/args.sh" | ||
| . "$GTR_DIR/lib/config.sh" | ||
| _ui_apply_color_config | ||
| . "$GTR_DIR/lib/platform.sh" | ||
| . "$GTR_DIR/lib/core.sh" | ||
| . "$GTR_DIR/lib/copy.sh" | ||
| . "$GTR_DIR/lib/hooks.sh" | ||
| . "$GTR_DIR/lib/provider.sh" | ||
| . "$GTR_DIR/lib/adapters.sh" | ||
| . "$GTR_DIR/lib/launch.sh" | ||
|
|
||
| # Source command handlers | ||
| for _cmd_file in "$GTR_DIR"/lib/commands/*.sh; do | ||
| # shellcheck disable=SC1090 | ||
| . "$_cmd_file" | ||
| # gtr - Convenience wrapper for git-gtr | ||
| # The main binary is bin/git-gtr; this wrapper allows ./bin/gtr for development. | ||
|
|
||
| # Find this script's real location (resolve symlinks) | ||
| SRC="${BASH_SOURCE[0]}" | ||
| while [ -h "$SRC" ]; do | ||
| DIR="$(cd -P "$(dirname "$SRC")" && pwd)" | ||
| SRC="$(readlink "$SRC")" | ||
| [[ $SRC != /* ]] && SRC="$DIR/$SRC" | ||
| done | ||
| unset _cmd_file | ||
|
|
||
| # Main dispatcher | ||
| main() { | ||
| local cmd="${1:-help}" | ||
| shift 2>/dev/null || true | ||
|
|
||
| # Set for per-command help (used by show_command_help in ui.sh) | ||
| _GTR_CURRENT_COMMAND="$cmd" | ||
|
|
||
| case "$cmd" in | ||
| new) | ||
| cmd_create "$@" | ||
| ;; | ||
| rm) | ||
| cmd_remove "$@" | ||
| ;; | ||
| mv|rename) | ||
| cmd_rename "$@" | ||
| ;; | ||
| go) | ||
| cmd_go "$@" | ||
| ;; | ||
| run) | ||
| cmd_run "$@" | ||
| ;; | ||
| editor) | ||
| cmd_editor "$@" | ||
| ;; | ||
| ai) | ||
| cmd_ai "$@" | ||
| ;; | ||
| copy) | ||
| cmd_copy "$@" | ||
| ;; | ||
| ls|list) | ||
| cmd_list "$@" | ||
| ;; | ||
| clean) | ||
| cmd_clean "$@" | ||
| ;; | ||
| doctor) | ||
| cmd_doctor "$@" | ||
| ;; | ||
| adapter|adapters) | ||
| cmd_adapter "$@" | ||
| ;; | ||
| config) | ||
| cmd_config "$@" | ||
| ;; | ||
| completion) | ||
| cmd_completion "$@" | ||
| ;; | ||
| init) | ||
| cmd_init "$@" | ||
| ;; | ||
| version|--version|-v) | ||
| echo "git gtr version $GTR_VERSION" | ||
| ;; | ||
| help|--help|-h) | ||
| cmd_help "$@" | ||
| ;; | ||
| *) | ||
| log_error "Unknown command: $cmd" | ||
| echo "Use 'git gtr help' for available commands" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| } | ||
| SCRIPT_DIR="$(cd -P "$(dirname "$SRC")" && pwd)" | ||
|
|
||
| # Run main | ||
| main "$@" | ||
| # Execute the main git-gtr script | ||
| exec "$SCRIPT_DIR/git-gtr" "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.