Multiple Custom Commands in Shell Startup (for Terminator)

If you use the shell extensively, I hope you know terminator by now. But, you know, this whole “writing a blog” thing will be pretty pointless if you already knew everything I wanted to say, so… I should probably elaborate.


This is a companion discussion topic for the original entry at http://amir.rachum.com/blog/2015/11/28/terminator-multiple-custom-commands/

For 1, look in the Profile tab, and the command tab. There you can set a custom profile to either exit (close), restart the command, or hold the terminal open.

For 2, by running a bash afterwards you replace the environment that the first command ran in. Something like:
bash --rcfile <(echo ". ~/.bashrc && workon project")
(Not sure if that will get mangled) will run source the bash rc, run the workon caommand, and crucially leave you in the same bash process.

These won't help with 3, and can't think of a solution right now.

I’ve tried using:

print -s “$cmd”

That didn’t work in my zsh environment, so I changed it to:

print -S “$cmd”

And it worked perfectly.

This is a great solution I have been looking for this for awhile. I am using bash and for anyone else using bash this is what worked for me.

Add this to your .bashrc file

Used in combination with terminator so that you can use custom layouts.

if [ ! -z “$INIT_CMD” ]; then
IFS=’;’
read -ra ADDR <<< $INIT_CMD
for cmd in “${ADDR[@]}”; do
history -s $cmd
eval $cmd
done
IFS=’ ’
unset INIT_CMD
fi

And then add this to the “Custom Command” section in terminator:
export INIT_CMD=“command 1; command 2; etc…”; bash