Question

Currently I have this gitconfig:

[diff]
    tool = diffmerge
[difftool "diffmerge"]
    cmd = diffmerge \"$LOCAL\" \"$REMOTE\"
[merge]
    tool = diffmerge
[mergetool "diffmerge"]
    cmd = "diffmerge --merge --result=\"$MERGED\" \"$LOCAL\" \"$(if test -f \"$BASE\"; then echo \"$BASE\"; else echo \"$LOCAL\"; fi)\" \"$REMOTE\""
    trustExitCode = true
[alias]
  df = difftool

Everytime I start the difftool via git difftool somefile..somefile, I get prompt:

Hit return to launch 'diffmerge':

How can I set up this prompt so, that if I type "Y" it opens the file, and if "N" it skips it?

Was it helpful?

Solution

This is a bit of a hack, but you could do:

[alias]
    df = difftool -y
[difftool "diffmerge"]
    cmd = sh -c 'read -p \"Type Y to launch diffmerge:\" r && \
        test $r = Y \
        && diffmerge \"$LOCAL\" \"$REMOTE\"'

This assumes your read accepts -p. If not, do the standard thing:

cmd = sh -c 'printf \"Type Y to launch diffmerge: \" && read r && test $r = Y \
            && diffmerge \"$LOCAL\" \"$REMOTE\"'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top