mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 14:03:58 +00:00
completions/git.fish: Sort in order of likelihood
In the presence of modified files, assume `git checkout ...` is being invoked/completed with the intention of restoring modifications. Even if not the case, this list is likely going to be shortest if someone is about to change branches. Afterwards, list branches (with local branches sorted by recency), then remote unique remotes, heads, tags, and recent commits. The order of these last four is up for debate, and honestly if any of them generate a lot of results it makes finding what you're actually looking for in the autocompletions a lot harder. It may be better to merge these last contenders and sort them by individual recency instead, but that does make the pager entries rather messy (and we would need to add a new function to do that in order to interleave them in the desired sort order but preserve the overall sort after the completions subshell terminates).
This commit is contained in:
parent
bef706b8f1
commit
acb77ad1a3
1 changed files with 7 additions and 4 deletions
|
@ -1122,13 +1122,16 @@ complete -c git -n '__fish_git_using_command am' -l show-current-patch -a 'diff
|
|||
### checkout
|
||||
complete -F -c git -n '__fish_git_using_command checkout' -n 'contains -- -- (commandline -opc)'
|
||||
complete -f -c git -n __fish_git_needs_command -a checkout -d 'Checkout and switch to a branch'
|
||||
complete -f -c git -n '__fish_git_using_command checkout' -ka '(__fish_git_files modified deleted modified-staged-deleted)'
|
||||
complete -f -c git -n '__fish_git_using_command checkout' -n 'not contains -- -- (commandline -opc)' -a '(__fish_git_recent_commits --kall)'
|
||||
|
||||
# The following dynamic, order-preserved (-k) completions will be shown in reverse order (see #9221)
|
||||
complete -f -c git -n '__fish_git_using_command checkout' -n 'not contains -- -- (commandline -opc)' -ka '(__fish_git_recent_commits --kall)'
|
||||
complete -f -c git -n '__fish_git_using_command checkout' -n 'not contains -- -- (commandline -opc)' -ka '(__fish_git_tags)' -d Tag
|
||||
complete -f -c git -n '__fish_git_using_command checkout' -n 'not contains -- -- (commandline -opc)' -ka '(__fish_git_heads)' -d Head
|
||||
complete -f -c git -n '__fish_git_using_command checkout' -n 'not contains -- -- (commandline -opc)' -ka '(__fish_git_unique_remote_branches)' -d 'Unique Remote Branch'
|
||||
complete -f -c git -n '__fish_git_using_command checkout' -n 'not contains -- -- (commandline -opc)' -ka '(__fish_git_branches)'
|
||||
complete -f -c git -n '__fish_git_using_command checkout' -n 'not contains -- -- (commandline -opc)' -ka '(__fish_git_heads)' -d Head
|
||||
complete -f -c git -n '__fish_git_using_command checkout' -n 'not contains -- -- (commandline -opc)' -ka '(__fish_git_local_branches)'
|
||||
# In the presence of changed files, `git checkout ...` assumes highest likelihood is intent to restore so this comes last (aka shown first).
|
||||
complete -f -c git -n '__fish_git_using_command checkout' -ka '(__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'
|
||||
complete -f -c git -n '__fish_git_using_command checkout' -s B -d 'Create a new branch or reset existing to start point'
|
||||
complete -f -c git -n '__fish_git_using_command checkout' -s t -l track -d 'Track a new branch'
|
||||
|
|
Loading…
Reference in a new issue