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?

link|improve this question
feedback

2 Answers

(Ab)using .bashrc is the only usable way.1 Generation is unnecessary, however – just put the command(s) in an environment variable and eval it:

  • Put the following at the end of your ~/.bashrc:

    [[ $startup_cmd ]] && {
        declare +x startup_cmd
        eval "$startup_cmd"
    }
    
  • Configure Terminator to start this command:

    env startup_cmd='vim' bash
    

1 Let's exclude the "use C4 to crack a nut" ones.

link|improve this answer
looks nice and works at the first glance... have to modify bashrc, could life with that... but for whatever reason, ctrl-z still does not work -- any idea? -- in what sort of cupboard would I find the c4-based solution? – marvin2k Oct 8 '11 at 23:19
feedback
bash -c 'vim; exec bash'

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

link|improve this answer
hm yeah... this solves the "empty split after exit" issue... but ctrl-z still does not work -- bash is simply executed again after vims exit... I need vim inside bash – marvin2k Oct 8 '11 at 22:46
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.