sublimehq / sublime_merge

Issue tracker for Sublime Merge
https://www.sublimemerge.com
276 stars 14 forks source link

Add command to launch external program #247

Open FichteFoll opened 5 years ago

FichteFoll commented 5 years ago

Problem description

There is the git command, but that only allows running git commands. It would be nice if there was a command to launch an external process using the various variables provided by menus etc. This could then be used to e.g. open the current repo in an editor of your choice or run whatever other tools you'd be interested in, like a terminal.

Preferred solution

A command similar to exec in ST, though without build results etc and just launching an external program.

Related: #201.

jskinner commented 5 years ago

This would be nice to have built in. FWIW it's possible to work around it as a temporary measure by making judicious use of git aliases - https://www.atlassian.com/blog/git/advanced-git-aliases

FichteFoll commented 4 years ago

While I have been using git aliases in the past, as they are still the only known and usable workaround, the downside of them is that Sublime Merge will not start a new git call until the old one is finished. Not even when you disown a job after you started it. That means you can't keep a terminal window for the current repository around, because SM cannot perform any git operations for as long as it is open.

Example:

[alias]
    terminal = !alacritty "$@" & disown

I can run this on a terminal and it returns immediately, but SM still tracks the spawned and orphaned child process.

Zwyx commented 1 year ago

The fact that Sublime Merge tracks the orphaned process it very annoying. I created a script which is supposed to detach itself from his creator:

[alias]
    my-script = !~/path/to/my-script.sh
# Beginning of `my-script.sh`:
if [[ "$1" != "-n" ]]; then
    nohup "$0" -n &
    disown
    exit $?
fi

but even with nohup and disown, Sublime is still tracking it.

FichteFoll commented 1 year ago

For some reason, after 3 years, it suddenly dawned on me that I could instead try to get something else to launch my process, e.g. i3-msg's exec command, which worked out just fine. That's obviously not a perfect and generally applicable solution, but it will work as a workaround for me.

Zwyx commented 1 year ago

I found the same kind of workout:

[alias]
    my-script = !gnome-terminal -- path/to/my-script.sh

It opens a terminal window so it's not perfect but it does the job: Sublime Merge returns immediately.

(I tried to then restart the command in background using the trick I mentioned above, in order to close the terminal window just after it opens. But that prevents Git from working — cannot read from remote. I had enough at this point :smile: so I don't do that and leave the terminal window open until my stuff is finished. Good enough!)