sublime_merge icon indicating copy to clipboard operation
sublime_merge copied to clipboard

Add command to launch external program

Open FichteFoll opened this issue 7 years ago • 6 comments

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.

FichteFoll avatar Nov 18 '18 14:11 FichteFoll

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

jskinner avatar Apr 16 '19 07:04 jskinner

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.

FichteFoll avatar Jun 06 '20 21:06 FichteFoll

The fact that Sublime Merge tracks the orphaned process is very annoying. I created a script which is supposed to detach itself from its 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.

Zwyx avatar Jun 20 '23 05:06 Zwyx

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.

FichteFoll avatar Jun 20 '23 18:06 FichteFoll

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!)

Zwyx avatar Jun 21 '23 00:06 Zwyx

Bumping this again because it would also be really handy to integrate various gh GitHub CLI commands into SM without having to create a git alias. Fortunately, you only need to add a single alias for gh = !gh and then simply have all further arguments appended to the gh call.

FichteFoll avatar Feb 16 '25 11:02 FichteFoll