- local title="$(get_terminal_title)"
- if [ "$title" != "unknown" ]; then
- # there was a title, so save it.
- if [ ! -z "$DEBUG_TERM_TITLE" ]; then
- echo "saving prior terminal title as '$title'"
- fi
- export PRIOR_TERMINAL_TITLE="$title"
- else
- # the terminal had no title, or we couldn't access it, or there's no terminal.
- if [ ! -z "$DEBUG_TERM_TITLE" ]; then
- echo "not saving prior terminal title which was empty"
+ # whack our output variable, just in case.
+ unset LAST_TITLE
+
+ if [ ! -z "$TERMINAL_TITLE_STACK" ]; then
+ LAST_TITLE="$(echo $TERMINAL_TITLE_STACK | sed -n -e 's/.*","\([^,]*\)"$/\1/p')"
+ if [ -z "$LAST_TITLE" ]; then
+ LAST_TITLE="$(echo $TERMINAL_TITLE_STACK | sed -n -e 's/"//gp')"