0

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.

2
  • When you mean "open", do you mean when you execute the bash file? Or when you want to edit its contents?
    – Corb3nik
    Commented Jul 14, 2014 at 2:29
  • I would like it to work like Windows does when you click on a bat file it opens cmd to display the output Commented Jul 14, 2014 at 14:16

1 Answer 1

0

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

7
  • This would require me to 2 bash files, no? Commented Jul 14, 2014 at 14:15
  • I assumed you have some and you are experiencing issues with running them. Writing in one script is a different matter, but you didn't say. Commented Jul 14, 2014 at 21:20
  • I would like bash files to open in terminal like Windows does, that way I may see there output Commented Jul 15, 2014 at 3:30
  • Again, are you going to write yours own scripts or run some already existed? Lust let me know, I will try to improve my answer. Commented Jul 15, 2014 at 4:09
  • I would like to write my own. Commented Jul 15, 2014 at 15:11

You must log in to answer this question.

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