Git mergetool completion (#3226)

* git completion: add mergetool

The list of tools is stole from the bash completion file that comes with
git.

* git completion: complete files with merget conflict for mergetool
This commit is contained in:
Frederik Gladhorn 2016-07-16 00:34:05 +02:00 committed by Fabian Homborg
parent 2df263fa26
commit 6b99af05a5

View file

@ -448,6 +448,31 @@ complete -f -c git -n '__fish_git_using_command merge' -l abort -d 'Abort the cu
# TODO options
### mergetool
function __fish_git_mergetools
set -l tools diffuse diffmerge ecmerge emerge kdiff3 meld opendiff tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
for tool in $tools
if command --search $tool >/dev/null
echo "$tool"
end
end
end
# returns list of files with status:
# "UU"=unmerged "\?\?"=untracked "M "=staged " M"=changed, not staged "MM"=staged and changed locally
function __fish_git_status --argument-names "statusmarker"
for line in (git status -s)
set -l filename (string replace -r "^$statusmarker\s+" "" $line)
and echo $filename
end
end
complete -f -c git -n '__fish_git_needs_command' -a mergetool -d 'Run merge conflict resolution tools to resolve merge conflicts'
complete -f -c git -n '__fish_git_using_command mergetool' -s t -l tool -d "Use specific merge resolution program" -a "(__fish_git_mergetools)"
complete -f -c git -n '__fish_git_using_command mergetool' -a "(__fish_git_status 'UU')" -d "File"
### mv
complete -c git -n '__fish_git_needs_command' -a mv -d 'Move or rename a file, a directory, or a symlink'
# TODO options