I would like to run a script that detects the current terminal and generates a new terminal window, in the background, with a shell command (e.g. htop
)
I get the desired outcome at the command line:
cterminal="$(ps -p $(ps -p $$ -o ppid=) o args=)"
$(echo $cterminal -e "htop")&
and works on all terminals. But not from a script:
#!/bin/bash
cterminal="$(ps -p $(ps -p $$ -o ppid=) o args=)"
echo $cterminal
"$cterminal" -e "htop" &
current script output:
$ bash script.sh
/bin/bash
$ /usr/bin/htop: /usr/bin/htop: cannot execute binary file
Any hints?