Skip to content

[bug]: Git branch completions not working #757

@cviebrock

Description

@cviebrock

What happened?

I recently switched from OMZ to oh-my-posh, but am trying to keep the alias and completions provided by the OMZ git and composer plugins. On my Linux machine, my .zshrc file looks like this:

export PATH=$HOME/bin:$PATH

# Set custom umask
umask 0007

export PAGER='less -X -F'

# zinit and plugins
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)"
[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
source "${ZINIT_HOME}/zinit.zsh"

zinit snippet OMZL::git.zsh
zinit ice atload"unalias grv"
zinit snippet OMZP::git
zinit snippet OMZP::composer

autoload -Uz compinit && compinit

# oh-my-posh prompt
eval "$(oh-my-posh init zsh --config ~/.mytheme.omp.json)"

# custom git aliases
alias grpo='git remote prune origin'
function gdrb() {
    git fetch -p
    git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs -r git branch -d
}

The aliases work (i.e. running aliases lists all the ones I'd expect from OMZ), but completions don't seem to work. Typing gsw then TAB to try and get a list of branches to switch to only pulls up the current directory listing (i.e. completion on the files, not git branches).

Steps to reproduce

  1. use the .zshrc file above
  2. move to a directory under git control with several branches
  3. type gsw and TAB to try and autocomplete a branch name
  4. note that it doesn't list the git branches and just tries to autocomplete from the filesystem

Relevant output

Screenshots and recordings

No response

Operating System & Version

OS: linux-gnu | Vendor: redhat | Machine: x86_64 | CPU: x86_64 | Processor: x86_64 | Hardware: x86_64

Zsh version

zsh 5.5.1 (x86_64-redhat-linux-gnu)

Terminal emulator

xterm-256color

If using WSL on Windows, which version of WSL

None

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions