Is there anyway to execute bash as interactive and run a command?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is there anyway to execute bash as interactive and run a command?
I'm trying to start bash with a command and have it interactive like this:
bash -i -c "echo Welcome!"
As in, execute the command and allow me to use it as an interactive shell afterwards. (I'm doing something more complicated than echoing, but this doesn't work.)
I've tried this from a running gnome-terminal, from one gnome-terminal to a new one with
gnome-terminal
and from the Alt+F2 program launcher (with "Run in terminal" ticked).
Here's the situation: Whilst programming junk, I like to have a couple of terminals open, to different directories, and one running ipython in the source directory. So I'm going to need to run a couple of different commands. I don't want to have to replace my .bashrc.
Yeah, that's what I'm trying to do. Except I'd like to do it from a script (easy) and have each of them execute a separate command (e.g., change directory, start ipython, set some environment variables). I reckon I could switch out the .bashrc before each call, but that seems like the wrong way to do it.
So the problem is to open a new terminal from the command line executing a command and keep it open for interactive usage, right? Take a look at a solution here. You can try to write a function that do the trick or even some aliases, each of them running a specific command.
That's exactly what I wanted. The gnome-terminal -x switch is the key, and it's not in the --help. It is in the man page, however, so I suppose I should have RTFM. :P
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.