Ubuntu – Open XFCE Terminal Window and Run command in same Window

bashcommand linexfcexfce4-terminal

I would like to start 'xfce4-terminal' and then run a command but finish with a prompt to repeat the command.

I use the software 'todo.txt' and like to have it open in a small window which I can refer to and add entries, etc.

At the moment, I have the following command line which works…

xfce4-terminal --title=todo &

…I then have to switch to that terminal window and type…

/usr/local/bin/todo.sh -t ls

I have the tried all these but on each try it 'finishes' the window and will not let me type in the window:-

xfce4-terminal --execute '/usr/local/bin/todo.sh -t ls' --title=todo --hold &

xfce4-terminal --command '/usr/local/bin/todo.sh -t ls' --title=todo --hold &

xfce4-terminal --command='/usr/local/bin/todo.sh -t ls' --title=todo &

Can anyone help please?

I would like to open the terminal window, run the command, then leave me with a working prompt.

Thanks.

Best Answer

Use -c option for bash command to wrap multiple commands, like this:

$ bash -c "ls /var/log/apt; bash"
history.log    history.log.4.gz  term.log.10.gz  term.log.5.gz
history.log.10.gz  history.log.5.gz  term.log.11.gz  term.log.6.gz
history.log.11.gz  history.log.6.gz  term.log.12.gz  term.log.7.gz
history.log.12.gz  history.log.7.gz  term.log.1.gz   term.log.8.gz
history.log.1.gz   history.log.8.gz  term.log.2.gz   term.log.9.gz
history.log.2.gz   history.log.9.gz  term.log.3.gz
history.log.3.gz   term.log      term.log.4.gz
username@hostname:~$ 

Then, use that bash command in xfce4-terminal command, like this:

xfce4-terminal -e 'bash -c "ls /var/log/apt; bash"' -T "Run and ready"

whereby the options: -e to run the commands, -T to set the title.

As a result, the terminal does not close and ready with a new prompt.