Bash, execute command but continue with interactive session Bash, execute command but continue with interactive session unix unix

Bash, execute command but continue with interactive session


My advice would be using a custom bashrc file with --rcfile that sources your .bashrc, ex :

alias admin=pagsh -c "bash --rcfile myrc"

myrc :

source ~/.bashrckinit xtoth1@ADMIN.META


If what you need is only a line or two, you can use the cool bash feature of "Process Substitution"[1] to provide it right on the invocation line. e.g. (to run a bash in a specific python virtualenv):

bash --rcfile <(echo '. ./pyvenv/bin/activate')

multiple lines are not a problem, nor is using vars or helpers:

bash --rcfile <(echo echo "Starting at `date`"; echo cd $HOME)

[1] man bash and look for "Process Substitution". Note that this is not supported on all systems, but it should work on all Linux.


What about following?

alias admin='pagsh -c "bash -c \"kinit xtoth1@ADMIN.META; exec bash\""'

or even

alias admin='pagsh -c "kinit xtoth1@ADMIN.META; exec bash"'

might work. (I do not have working openafs environment around to test it properly.)