mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 05:43:11 +00:00
Fix git ranges completion, add gitk and tig
[ci skip]
This commit is contained in:
parent
6699a72e0e
commit
15817a0b07
4 changed files with 58 additions and 1 deletions
|
@ -22,10 +22,12 @@
|
|||
|
||||
#### Completions
|
||||
- Added completions for
|
||||
- `gitk`
|
||||
- `wireshark`, `tshark`, and `dumpcap`
|
||||
- `dropdb`, `createdb`, `pg_restore`, `pg_dump` and `pg_dumpall`
|
||||
- `dhclient`
|
||||
- `tcpdump`
|
||||
- `tig`
|
||||
|
||||
### Deprecations and removed features
|
||||
|
||||
|
|
|
@ -515,7 +515,7 @@ function __fish_git_ranges
|
|||
|
||||
set -l to $both[2]
|
||||
# Remove description from the from-ref, not the to-ref.
|
||||
for from_ref in (__fish_git_refs | string match "$from" | string replace -r \t'.*$' '')
|
||||
for from_ref in (__fish_git_refs | string match -e "$from" | string replace -r \t'.*$' '')
|
||||
for to_ref in (__fish_git_refs | string match "*$to*") # if $to is empty, this correctly matches everything
|
||||
printf "%s..%s\n" $from_ref $to_ref
|
||||
end
|
||||
|
|
27
share/completions/gitk.fish
Normal file
27
share/completions/gitk.fish
Normal file
|
@ -0,0 +1,27 @@
|
|||
# gitk - The Git repository browser
|
||||
|
||||
source $__fish_data_dir/completions/git.fish
|
||||
|
||||
complete -c gitk -f -n 'not contains -- -- (commandline -opc)' -a '(__fish_git_ranges)'
|
||||
complete -c gitk -n 'contains -- -- (commandline -opc)' -F
|
||||
|
||||
complete -c gitk -l all -d 'Show all refs (branches, tags, etc.)'
|
||||
complete -c gitk -l since=YYYY-MM-DD -x -d 'Show commits more recent that a specific date'
|
||||
complete -c gitk -l until=YYYY-MM-DD -x -d 'Show commits older than a specific date'
|
||||
complete -c gitk -l date-order -d 'Sort commits by date when possible'
|
||||
complete -c gitk -l merge -d 'On a merge conflict, show commits that modify conflicting files'
|
||||
complete -c gitk -l left-right -d 'Mark which side of a symmetric difference a commit is reachable from'
|
||||
complete -c gitk -l full-history -d 'When filtering history with -- path..., do not prune some history'
|
||||
complete -c gitk -l simplify-merges -d 'Hide needless merges from history'
|
||||
complete -c gitk -l ancestry-path -d 'Only display commits that exist directly on the ancestry chain between the given range'
|
||||
complete -c gitk -l argscmd= -d 'Command to be run to determine th revision range to show'
|
||||
complete -c gitk -l select-commit= -d 'Select the specified commit after loading the graph, instead of HEAD'
|
||||
complete -c gitk -l select-commit=HEAD -d 'Select the specified commit after loading the graph, instead of HEAD'
|
||||
complete -c gitk -n 'string match -rq -- "^--select-commit=" (commandline -ct)' -xa '(printf -- "--select-commit=%s\n" (__fish_git_refs))'
|
||||
complete -c gitk -s n -l max-count -x -d 'Limit the number of commits to output'
|
||||
complete -c gitk -xa -L1 -d '-L<start>,<end>:<file> trace the evolution of a line range'
|
||||
complete -c gitk -xa -L. -d '-L<funcname>:<file> trace the evolution of a function name regex'
|
||||
complete -c gitk -n 'string match -rq -- "^-L[^:]*": (commandline -ct)' -xa '(
|
||||
set -l tok (string split -m 1 -- : (commandline -ct))
|
||||
printf -- "$tok[1]:%s\n" (complete -C": $tok[2]")
|
||||
)'
|
28
share/completions/tig.fish
Normal file
28
share/completions/tig.fish
Normal file
|
@ -0,0 +1,28 @@
|
|||
# tig - text-mode interface for Git
|
||||
|
||||
not functions -q __fish_git && source $__fish_data_dir/completions/git.fish
|
||||
|
||||
set -l subcommands log show reflog blame grep refs statsh status
|
||||
complete -c tig -n "not __fish_seen_subcommand_from $subcommands" -xa 'show\t"Open diff view using the given git-show(1) options"
|
||||
blame\t"Annotate the given file, takes git-blame(1) options"
|
||||
status\t"Start up in status view"
|
||||
log\t"Start up in log view view, displaying git-log(1) output"
|
||||
reflog\t"Start up in reflog view"
|
||||
refs\t"Start up in refs view"
|
||||
stash\t"Start up in stash view"
|
||||
grep\t"Open the grep view. Supports the same options as git-grep(1)"
|
||||
'
|
||||
complete -c tig -l stdin -d 'Read git commit IDs from stdin'
|
||||
complete -c tig -l pretty=raw -d 'Read git log output from stdin'
|
||||
complete -c tig -o C. -d 'Run as if Tig was started in .'
|
||||
complete -c tig -s v -l version -d 'Show version and exit'
|
||||
complete -c tig -s h -l help -d 'Show help message and exit'
|
||||
|
||||
complete -c tig -n '__fish_seen_subcommand_from show' -xa '(set -l t (commandline -ct); complete -C"git show $t")'
|
||||
complete -c tig -n '__fish_seen_subcommand_from blame' -xa '(set -l t (commandline -ct); complete -C"git blame $t")'
|
||||
complete -c tig -n '__fish_seen_subcommand_from log' -xa '(set -l t (commandline -ct); complete -C"git log $t")'
|
||||
complete -c tig -n '__fish_seen_subcommand_from grep' -xa '(set -l t (commandline -ct); complete -C"git grep $t")'
|
||||
|
||||
complete -c tig -f -n 'not contains -- -- (commandline -opc)' -a '(__fish_git_ranges)'
|
||||
complete -c tig -n 'contains -- -- (commandline -opc)' -F
|
||||
|
Loading…
Reference in a new issue