- # save the former terminal title if we're running in X with xterm.
- which xprop &>/dev/null
- if [ $? -eq 0 ]; then
- # make sure we're actually using xterm *and* that we have a window ID.
- if [[ "$TERM" =~ .*"xterm".* && ! -z "$WINDOWID" ]]; then
- local prior_title="$(xprop -id $WINDOWID | perl -nle 'print $1 if /^WM_NAME.+= \"(.*)\"$/')"
- if [ ! -z "$prior_title" ]; then
-#echo "saving prior terminal title as '$prior_title'"
- push_ptt_stack "$prior_title"
-# else
-#echo "not saving prior terminal title which was empty"
- fi
+ # 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')"