6

I need to run the command right after the bash starts and then stay in the session. I was expecting something like that would work bash && cd ~/Work, but, apparentely, it would run the second command in the initial session, not the one I'm starting.

I've found this run bash command in new shell and stay in new shell after this command executes thread, but running bash --rcfile doesn't work for me, because I still need the rcfile to be loaded.

Community
  • 1
  • 1
orion3
  • 9,797
  • 14
  • 67
  • 93
  • possible duplicate of [Invoke bash, run commands inside new shell, then give control back to user](http://stackoverflow.com/questions/7120426/invoke-bash-run-commands-inside-new-shell-then-give-control-back-to-user) – Ciro Santilli OurBigBook.com Apr 09 '14 at 18:47

1 Answers1

7

You can still use --rcfile, you just need to include the sourcing of the default rc file in your command list:

bash --rcfile <(echo ". ~/.bashrc && cd ~/Work")
Carl Norum
  • 219,201
  • 40
  • 422
  • 469