Opening a terminal in a shell script, running a command on it, and keeping it open [duplicate]
You need to specify what the terminal to do after executing the command source bin/activate
. You want an active bash session so you need to run bash
. In addition there is a mes with the quotes. So the script could be:
#!/usr/bin/env bash
konsole --noclose --workdir /my/work/dir/ -e 'bash -c "source bin/activate; exec bash"' &
&
at the end is added in order to keep the main terminal usable, in case you are executing that script from other terminal window.the
exec
command could be omitted, and you can use onlybash
.
Here are few answers of similar questions, dedicated to gnome-terminal
:
how can I open a extra console and run a program in it with one command?
Open a new terminal and source scripts
How to open one (or more) gnome-terminal window with few tabs, each with different profile, when start/reboot the computer?
I am not able to comment, but from what I understand I may suggest
#!/bin/bash
cd /my/work/dir/
source bin/activate
konsole