I have a bash script that starts a terminal window with multiple tabs and executes a command in each of the tabs similar to this (and titles aren't supported, I know):
#!/bin/bash
title1="foo"
title2="bar"
cmd1="sleep 1s"
cmd2="cd ~/Desktop"
gnome-terminal --tab --title="$title1" --command="bash -c '$cmd1; $SHELL'" \
--tab --title="$title2" --command="bash -c '$cmd2; $SHELL'"
In the real script, when the process in one of the tabs dies, I have to restart it, usually. However, pressing the UP key doesn't yield the command used in the script in that tab. This behavior is the same with this script, as if I press up in the first tab I don't get "sleep 1s" but a completely different command I used elsewhere.
Is there a way for the opened tab to keep the $cmd used in the script?