I don't know of any way to invoke bash and tell it to execute some specified commands and then go into interactive mode. In your case, as you've seen, the bash -o vi
command will execute first, and will continue until that shell exits; only then will csh (attempt to) execute the cd
and .
commands (and since .
isn't a csh builtin, it will probably fail).
I'm assuming from your use of -o vi
that you want an interactive bash shell, though you didn't actually say so.
bash will execute commands in certain files on startup, depending on whether it's a login shell or not (.profile
, .bash_profile
, .bashrc
, etc.). See the bash documentation for details on which file is executed in which circumstances.
To have bash execute those commands on startup, put them in, for example, $HOME/.bashrc
. If you don't want them executed every time bash runs, you can control them with an environment variable.
For example, in csh:
alias setbash 'env USE_BASHDIR=1 bash -o vi'
and in .bashrc
:
if [ "$USE_BASHDIR" ] ; then
cd bashdir
./.profile
fi
(You can also do set -o vi
in .bashrc
rather than passing -o vi
on the command line.)
In the long run, though, you'll probably be better off using just bash and abandoning csh. (I used tcsh for many years and I've finally dropped it in favor of bash.)