From 6b99af05a502592b0db481a89ece09d1234dd61e Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Sat, 16 Jul 2016 00:34:05 +0200 Subject: [PATCH] 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 --- share/completions/git.fish | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/share/completions/git.fish b/share/completions/git.fish index 04cb07691..1b52b1d3a 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -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