-
Notifications
You must be signed in to change notification settings - Fork 68
Closed
Description
Summary
Two related issues when using git-gtr on a system with GNU coreutils installed via Homebrew.
Issues
1. gtr binary conflicts with coreutils
brew install coreutils provides /opt/homebrew/bin/gtr (GNU tr). Installing git-gtr via Homebrew fails to link because of this conflict:
$ brew link git-gtr
Error: Could not symlink bin/gtr
Target /opt/homebrew/bin/gtr
is a symlink belonging to coreutils.
This causes brew link to fail entirely, which also prevents the zsh/bash/fish completion files from being symlinked.
2. git gtr init zsh shadows coreutils gtr
Even without the binary conflict, eval "$(git gtr init zsh)" defines a gtr() shell function that shadows the coreutils gtr command. Additionally, gtr cd <tab> doesn't complete worktree names since cd is not listed in the completion file.
Workaround
My current workaround is to skip git gtr init zsh and define a custom function with completions (which gtr cd is currently missing):
if command -v git-gtr &> /dev/null; then
function gcd {
local dir
dir="$(git gtr go "$@")" && cd "$dir"
}
function _gcd {
local -a worktrees
worktrees=("1" ${(f)"$(git gtr list --porcelain 2>/dev/null | cut -f2)"})
_describe 'worktrees' worktrees
}
compdef _gcd gcd
fiSuggested fixes
- Consider removing the
gtrshorthand binary —git gtralready works as a git subcommand, and the shorthand conflicts with coreutils. The shell init could alias it for users who want it. - Consider adding
cdto the completion file, and usinggit gtr list --porcelaininstead ofgit branchfor worktree name completions
Environment
- macOS (Apple Silicon)
- Homebrew, with
coreutilsinstalled - git-gtr 2.3.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels