Linux Mint: Make a script/shortcut that can be clicked and run and will KEEP THE TERMINAL WINDOW OPEN afterwards

13,452

Create a script by your favorite method, e.g. right-click on your desktop > Create Document > name it 'test.sh' > Right click on the document > Properties > Permissions > Allow executing (or use chmod from terminal)

Open it for editing with gedit, KWrite, vt etc.

Here is a script which will run some commands in the parent terminal, run two more commands in a child terminal, and leave both terminals open!

#!/bin/bash
echo hello
# open a child window, run two commands in it, and leave the child window open
mate-terminal -e "bash -c \"echo foo; echo bar; exec bash\""  
echo "keep this open"
# leave the parent window open
read 

Save the file, click and select "Run in Terminal."

An alternate way to keep the terminal windows from closing is: Open a terminal > Edit menu > Profile Preferences > Title and Command > When Command Exits > Change from "Exit the terminal" to "HOLD THE TERMINAL OPEN"

Line 4 in the script is thanks to
Avoid gnome-terminal close after script execution?

Share:
13,452

Related videos on Youtube

Nissim Nanach
Author by

Nissim Nanach

נ נח Geotechnics PhD in Mathematics

Updated on September 15, 2022

Comments

  • Nissim Nanach
    Nissim Nanach about 1 year

    I make a shortcut on the desktop to run some commands in a terminal.
    I click it and the terminal window just opens and closes!

    Also, I would like to be able to have the script open a second terminal which will run some more commands and also remain open.