git difftool holding the shell
Asked Answered
B

2

6

I'm using git bash for Windows with Beyond & Compare as my difftool (but the same thing occures with any external difftool).

I would like my terminal not to be waiting for the difftool to exit in order to give terminal control back. It would be useful for me to keep the difftool session opened while performing other git tasks in the command line.

Is it possible ?

I don't know if this has anything to do with trustexistcode but this setting won't change anything to the terminal behavior I'm looking for.

Bryant answered 23/9, 2016 at 4:41 Comment(2)
This is a general feature of terminal, not something that is specific to git or difftool. You can try putting a & after the command, i.e. git difftool &.Flay
Also, ctrl + z on the terminal might work after you have launched the difftool - not sure about the behaviour on windows though.Flay
B
3

At the time I asked the question I didn't know I could simply exit the handle (which is only waiting for the external tool to emit its exit code), using Ctrl + C.

This is not automatic but it is enough to get going.

EDIT - better solution : as suggested in @1615903's comment, putting an & after the difftool command seems to be launching the difftool without any handle.

Bryant answered 13/2, 2017 at 8:54 Comment(4)
Does Ctrl+C unblock the console and leave Beyond Compare open for you? For me, Ctrl+C in the console closes Beyond Compare, which is not what I want to happen. (Suggestions in other comments, & and Ctrl+Z, don't work for me, either.)Clactonian
@Clactonian I agree, BC seems to be taking Ctrl+C as an exiting command (or something). I just updated the solution : using & works well to get the terminal back even while BC is running.Bryant
Really? How do you type it in? I tried "git difftool --dir-diff &" and it seemed to have no effect.Clactonian
I write it exactly like you said, it returns something like this : [1] 560 then gives back the handle. It seems the number 560 refers to the PID of the current bash process. The number in the brackets is like a count of how many times I entered the command.Bryant
R
0

The solution I found was to use an alias'd function. The quoted $@ is important, as on windows folder names with spaces are common.

start_git_difftool() {
    if [ "$#" -eq  "0" ]
    then
        git difftool --dir-diff &
    else
        git difftool "$@" &
    fi
}

start_bcomp() {
    BCompare.exe "$@" &
}

alias bcomp=start_bcomp
alias gdiff=start_git_difftool
Resistive answered 9/10, 2020 at 15:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.