bash: execute command given in commandline and don't exit

how do I specifiy a command on the commmandline of bash which shall be executed once inside the new bash after reading ~/.bashrc -- But all this without letting bash exit after the command is finished?

I'm fiddling around with a "boot-up-configuration" for terminator where some splits should start some applications (vim, mutt, irrsi) after startup. But I still want normal shells in the background (ctrl-z and so on...) so after quitting an application I have the same shell which I had during the eapplications lifetime...

What does not work for me (based on given answers)

 ( bash; vim )              # vim waits for the exit of bash...
 bash -c vim                # bash exits after vims exit...
 bash -c 'vim; exec bash'   # bash is executed _after_ vim... ctrl-z won't work
 echo vim | bash -s         # "Vim: Warning: Input is not from a terminal"     

Manually appending "vim" to a temporary bashrc does not work either. vim starts up correctly, but there is still no background bash present where a ctrl-z would bring me to.

Any suggestions?


Solution 1:

I seem to have found a way to solve this so that the job control works:

bash --rcfile <(cat ${HOME}/.bashrc; echo 'export PROMPT_COMMAND="vim; export PROMPT_COMMAND="') -i

This creates custom bashrc file on the fly and uses PROMPT_COMMAND variable to delay the Vim start so that job control should work. This of course can be generalized to not be Vim specific.

Ok, just tested this with terminator and at least seems to work with config file:

[profiles]
[[default]]
    use_custom_command = True
    custom_command = "bash --rcfile <(cat ${HOME}/.bashrc; echo 'export PROMPT_COMMAND="vim; export PROMPT_COMMAND="') -i"

Solution 2:

bash -c 'vim; exec bash'

The exec bash will replace the current Bash instance with a new one.