TransWikia.com

Bash files open terminal when opened

Super User Asked by Chris Smith on December 31, 2020

This seems like something simple to do but for the life of me I cannot figure out how to do it. I would like all bash (*.sh, *.bash) files to open with a terminal to show their output in.

One Answer

If you are going to run some script from GUI and be able to see its output you can wrap a target script into your own one. You new script calls terminal->bash->your_script and waits until it finishes and exits. In the script below change ./script.sh to your script name and path.

#!/bin/bash
# Bash Menu Script Example

xterm -e "bash -c "./script.sh; exec bash"" &
while [ `pidof xterm` ]
do
wait `pidof xterm`
done

UPDATE:

According to these close popular answers you need to have two scripts in your case.

If you are going to run some script from GUI and be able to see its output you need to enable it.

From Nautilus:

enter image description here

And them when you click your script you will be asked:

enter image description here

From command line:

gnome-terminal -e command

or

xterm -e command

or

konsole -e command

or

terminal -e command

To make the terminal stay when the command exits:

In konsole there is a --noclose flag.

In xterm, there is a -hold flag.

In gnome-terminal, go to Edit -> Profile Preferences -> Title. Click the Command tab. Select Hold the terminal from the drop-down menu labelled When command exits.

enter image description here

You should create a new profile for that and execute with

gnome-terminal --window-with-profile=NAMEOFTHEPROFILE -e command

Answered by Ruslan Gerasimov on December 31, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP