Skip to content

Commit 7e4d746

Browse files
authored
refactor: keep local branch list order in completions for certain commands (#60)
This MR prevents the default **local* branch list sorting (alphabetical order) in completions (current behaviour) and preserves git branch sorting by **recency** instead (via `__fish_git_branches`). Those changes will help navigate to latest committed branches quickly in completions when using either `move`, `merge` or `tag` commands. In particular, when having many local branches. See Fish shell `complete` command for more details. Commands affected: - merge - move - tag
1 parent 7960ed8 commit 7e4d746

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

completions/merge.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
__gitnow_load_git_functions
77

8-
complete -f -x -c merge -a '(__fish_git_branches)'
8+
complete -f -k -x -c merge -a '(__fish_git_branches)'
99

1010
complete -f -x -c merge \
1111
-s h -l help \

completions/move.fish

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@
55

66
__gitnow_load_git_functions
77

8-
complete -f -x -c move -a '(__fish_git_branches)'
8+
complete -f -k -x -c move -a '(__fish_git_branches)'
99

10-
complete -f -x -c move \
10+
complete -f -k -x -c move \
1111
-s h -l help \
1212
-d "Show information about the options for this command"
1313

1414
complete -f -x -c move \
1515
-s p -l prev \
1616
-d "Switch to a previous branch using the `--no-apply-stash` option (equivalent to \"move -\")"
1717

18-
complete -f -x -c move \
18+
complete -f -k -x -c move \
1919
-s n -l no-apply-stash \
2020
-a '(__fish_git_branches)' \
2121
-d "Switch to a local branch but without applying current stash"
2222

23-
complete -f -x -c move \
23+
complete -f -k -x -c move \
2424
-s u -l upstream \
2525
-a '(__fish_git_branches)' \
2626
-d "Fetch a remote branch and switch to it applying current stash"
2727

28-
complete -f -x -c move \
28+
complete -f -k -x -c move \
2929
-s r -l remote-branch \
3030
-n 'contains -- -u (commandline -opc); or contains -- --upstream (commandline -opc)' \
3131
-a '(__fish_git_branches)' \

completions/tag.fish

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
__gitnow_load_git_functions
77

8-
complete -f -x -c tag \
8+
complete -f -k -x -c tag \
99
-d "List all tags in a lexicographic order and treating tag names as versions"
1010

11-
complete -f -x -c tag -a '(__fish_git_tags)'
11+
complete -f -k -x -c tag -a '(__fish_git_tags)'
1212

1313
complete -f -x -c tag \
1414
-s h -l help \

0 commit comments

Comments
 (0)