From a4a48b38f7705edb4c47c48f27b54c56309120ce Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 15 Oct 2021 01:36:14 +0800 Subject: [PATCH] Display local branches before unique remote branches in git completion (#8338) Usually local branches have remote branches with the same name, and in completion they are currently overshadowed by unique remote branches, making local branches hard to find. Define local branch completion after unique remote branch completion to show local branches before unique remote branches. --- share/completions/git.fish | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/share/completions/git.fish b/share/completions/git.fish index 2751e5f87..338023594 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -1026,6 +1026,7 @@ complete -k -f -c git -n '__fish_git_using_command checkout; and not contains -- complete -k -f -c git -n '__fish_git_using_command checkout; and not contains -- -- (commandline -opc)' -a '(__fish_git_heads)' -d Head complete -k -f -c git -n '__fish_git_using_command checkout; and not contains -- -- (commandline -opc)' -a '(__fish_git_branches)' complete -k -f -c git -n '__fish_git_using_command checkout; and not contains -- -- (commandline -opc)' -a '(__fish_git_unique_remote_branches)' -d 'Unique Remote Branch' +complete -k -f -c git -n '__fish_git_using_command checkout; and not contains -- -- (commandline -opc)' -a '(__fish_git_local_branches)' complete -k -f -c git -n '__fish_git_using_command checkout; and not contains -- -- (commandline -opc)' -a '(__fish_git_recent_commits --all)' complete -k -f -c git -n '__fish_git_using_command checkout' -a '(__fish_git_files modified deleted modified-staged-deleted)' complete -f -c git -n '__fish_git_using_command checkout' -s b -d 'Create a new branch' @@ -1764,8 +1765,8 @@ complete -f -c git -n '__fish_git_using_command restore; and contains -- --stage complete -F -c git -n '__fish_git_using_command restore; and __fish_contains_opt -s s source' # switch options complete -f -c git -n __fish_git_needs_command -a switch -d 'Switch to a branch' -complete -k -f -c git -n '__fish_git_using_command switch' -a '(__fish_git_local_branches)' complete -k -f -c git -n '__fish_git_using_command switch' -a '(__fish_git_unique_remote_branches)' -d 'Unique Remote Branch' +complete -k -f -c git -n '__fish_git_using_command switch' -a '(__fish_git_local_branches)' complete -f -c git -n '__fish_git_using_command switch' -r -s c -l create -d 'Create a new branch' complete -f -c git -n '__fish_git_using_command switch' -r -s C -l force-create -d 'Force create a new branch' complete -f -c git -n '__fish_git_using_command switch' -s d -l detach -d 'Switch to a commit for inspection and discardable experiment' -k -ra '(__fish_git_refs)' @@ -1858,6 +1859,7 @@ complete -k -c git -n '__fish_git_using_command worktree; and __fish_seen_subcom complete -k -c git -n '__fish_git_using_command worktree; and __fish_seen_subcommand_from add' -a '(__fish_git_heads)' -d Head complete -k -c git -n '__fish_git_using_command worktree; and __fish_seen_subcommand_from add' -a '(__fish_git_tags)' -d Tag complete -k -c git -n '__fish_git_using_command worktree; and __fish_seen_subcommand_from add' -a '(__fish_git_unique_remote_branches)' -d 'Unique Remote Branch' +complete -k -c git -n '__fish_git_using_command worktree; and __fish_seen_subcommand_from add' -a '(__fish_git_local_branches)' complete -x -c git -n '__fish_git_using_command worktree; and __fish_seen_subcommand_from add' -s b -d 'Create a new branch' complete -x -c git -n '__fish_git_using_command worktree; and __fish_seen_subcommand_from add' -s B -d 'Create a new branch even if it already exists' complete -f -c git -n '__fish_git_using_command worktree; and __fish_seen_subcommand_from add' -l detach -d 'Detach HEAD in the new working tree'