mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
git completions: Add commit hashes for show
That's probably the part where commit hashes are most used, we can add the other subcommands later. This generates a _lot_ of options, so hooking it up everywhere would be unwise, though our pager helps quite nicely with filtering - typing "Branch" will filter out the commits, and typing other things will filter the subjects, which is quite cool.
This commit is contained in:
parent
8a6f26ff9b
commit
836b6bea73
1 changed files with 10 additions and 0 deletions
|
@ -1,6 +1,15 @@
|
||||||
# fish completion for git
|
# fish completion for git
|
||||||
# Use 'command git' to avoid interactions for aliases from git to (e.g.) hub
|
# Use 'command git' to avoid interactions for aliases from git to (e.g.) hub
|
||||||
|
|
||||||
|
function __fish_git_commits
|
||||||
|
# Complete commits with their subject line as the description
|
||||||
|
# This allows filtering by subject with the new pager!
|
||||||
|
# Because even subject lines can be quite long,
|
||||||
|
# trim them (abbrev'd hash+tab+subject) to 70 characters
|
||||||
|
command git log --pretty=tformat:"%h"\t"%s" \
|
||||||
|
| string replace -r '(.{70}).+' '$1...'
|
||||||
|
end
|
||||||
|
|
||||||
function __fish_git_branches
|
function __fish_git_branches
|
||||||
command git branch --no-color -a ^/dev/null | __fish_sgrep -v ' -> ' | string trim -c "* " | string replace -r "^remotes/" ""
|
command git branch --no-color -a ^/dev/null | __fish_sgrep -v ' -> ' | string trim -c "* " | string replace -r "^remotes/" ""
|
||||||
end
|
end
|
||||||
|
@ -219,6 +228,7 @@ complete -f -c git -n "__fish_git_using_command remote; and __fish_seen_subcomma
|
||||||
complete -f -c git -n '__fish_git_needs_command' -a show -d 'Shows the last commit of a branch'
|
complete -f -c git -n '__fish_git_needs_command' -a show -d 'Shows the last commit of a branch'
|
||||||
complete -f -c git -n '__fish_git_using_command show' -a '(__fish_git_branches)' -d 'Branch'
|
complete -f -c git -n '__fish_git_using_command show' -a '(__fish_git_branches)' -d 'Branch'
|
||||||
complete -f -c git -n '__fish_git_using_command show' -a '(__fish_git_unique_remote_branches)' -d 'Remote branch'
|
complete -f -c git -n '__fish_git_using_command show' -a '(__fish_git_unique_remote_branches)' -d 'Remote branch'
|
||||||
|
complete -f -c git -n '__fish_git_using_command show' -a '(__fish_git_commits)'
|
||||||
# TODO options
|
# TODO options
|
||||||
|
|
||||||
### show-branch
|
### show-branch
|
||||||
|
|
Loading…
Reference in a new issue