0

I have a fairly unusual use case, in which I often need to launch a custom program from the command line, which is a self-contained executable called ./Rustlinks contained in $HOME/Applications. Because I need to open this program often, I've made an alias to do this quickly:

alias rustlinks='~/Applications/Rustlinks \ exit'

Unfortunately, every time I run the rustlinks command, I have to close both the GUI window of Rustlinks, and the terminal window. This becomes a non-trivial matter because these terminal windows begin piling up easily.

To try to solve this issue, I've written a simple bash script, shown below:

#!/usr/bin/env bash
./Rustlinks
if [ $? -eq 0 ]
then
  killall gnome-terminal
else
  exit
fi

Now, I just need to run bash ~/Applications/rustlinks.sh (this script) to get my desired functionality. Unfortunately, this closes all terminal windows, which is not ideal.

Any better solutions would be highly appreciated.

2 Answers 2

0

Untested, but you probably want:

alias rustlinks='gnome-terminal -e ~/Applications/Rustlinks'

OK try this:

alias rustlinks='exec ~/Applications/Rustlinks'

This one will replace the running shell process with the app. When the app exits, that terminal window/tab should exit as well (assuming that's how you've configured gnone-terminal)

1
  • This would open a new terminal, so unfortunately not.
    – JS4137
    Apr 6, 2021 at 18:08
0

Figured out a solution:

  • The following command runs the executable, then exits the shell
  • Exiting the shell across most terminals also ends the terminal window process and thus closes the window as well
alias rustlinks='~/Applications/Rustlinks && exit'
  • Then running the rustlinks command automatically exits the terminal once the application is closed!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .