diff options
author | Fabian Homborg <FHomborg@gmail.com> | 2015-12-18 17:07:43 +0100 |
---|---|---|
committer | Fabian Homborg <FHomborg@gmail.com> | 2015-12-18 17:07:43 +0100 |
commit | 836b6bea73b6e8da657471d8b919ed347dfa62e5 (patch) | |
tree | e8fc3a6226c5e300eb53147887b7cba558e0a21b | |
parent | 8a6f26ff9bd260101b56b1de39adbf5992fb27a8 (diff) |
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.
-rw-r--r-- | share/completions/git.fish | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/share/completions/git.fish b/share/completions/git.fish index 076a54a9..acb3ff42 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -1,6 +1,15 @@ # fish completion for git # 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 command git branch --no-color -a ^/dev/null | __fish_sgrep -v ' -> ' | string trim -c "* " | string replace -r "^remotes/" "" 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_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_commits)' # TODO options ### show-branch |