How can I keep terminal running after closing app?

I created a desktop shortcut to run a script. However, I am not sure how I can keep terminal open once I close the app or if it crashes. I am fairly new to coding so please forgive me if this has been asked before. I tried other forums posts but I couldn't seem to get it to work for this one.

Name=Test
Comment=
Exec=bash -c "$HOME/test_folder/scripts/test.sh"
Icon=/usr/share/icons/test.png
Terminal=true
Type=Application
StartupNotify=true

The terminal window cannot remain open without a program running in it. So in order to keep the terminal open you have to make sure the command running in it does not exit. There are various ways to achieve this. One aspect that needs consideration is when and how the terminal shall be closed eventually.

In your case, since your command is bash running a script which you control, perhaps the simplest solution is to add the line:

read -p "Press ENTER to continue"

to the end of that script. This will cause the script to wait for a line of input before exiting, so the terminal will only close when you hit the ENTER key while it has the focus.

If your Exec= line contains a command you cannot or do not want to modify then an alternative solution would be to append the read command to it, for example:

Exec=/bin/bash -c '/usr/local/bin/coolprog ; read -p "Press any key to continue"'

The terminal will start a shell to run this command line, and the read command will cause that shell to wait for a line of input before exiting.


  • On your Exec= line, remove the bash -c " and ¨ at the end: there is no need. Just directly specify the full pathname of your script if it is not in a directory in your PATH.
  • Edit your script, and add a line bash. that way, the terminal will stay open on a prompt after the previous command in the script has finished.