source "$FEISTY_MEOW_LOADING_DOCK/custom/scripts/pick_credentials.sh"
-# save the former terminal title if we're running in X with xterm.
-prior_title=
-which xprop &>/dev/null
-if [ $? -eq 0 ]; then
- if [[ "$TERM" =~ .*"xterm".* ]]; then
- prior_title="$(xprop -id $WINDOWID | perl -nle 'print $1 if /^WM_NAME.+= \"(.*)\"$/')"
+if [ -z "$PRIOR_TERMINAL_TITLE" ]; then
+ # save the former terminal title if we're running in X with xterm.
+ PRIOR_TERMINAL_TITLE=
+ which xprop &>/dev/null
+ if [ $? -eq 0 ]; then
+ if [[ "$TERM" =~ .*"xterm".* ]]; then
+ PRIOR_TERMINAL_TITLE="$(xprop -id $WINDOWID | perl -nle 'print $1 if /^WM_NAME.+= \"(.*)\"$/')"
+ fi
fi
fi
if [ -z "$(echo $* | grep git)" ]; then
# re-run the terminal labeller after coming back from ssh.
# we check the exit value because we don't want to update this for a failed connection.
- if [ -z "$prior_title" ]; then
-#echo prior title nil new label
+ if [ -z "$PRIOR_TERMINAL_TITLE" ]; then
+echo prior title nil new label
bash $FEISTY_MEOW_SCRIPTS/tty/label_terminal_with_infos.sh
else
-#echo "using old prior title of '$prior_title'"
- bash $FEISTY_MEOW_SCRIPTS/tty/set_term_title.sh "$prior_title"
+echo "using old prior title of '$PRIOR_TERMINAL_TITLE'"
+ bash $FEISTY_MEOW_SCRIPTS/tty/set_term_title.sh "$PRIOR_TERMINAL_TITLE"
+ # remove the value for this, since we did our job on it.
+ unset PRIOR_TERMINAL_TITLE
fi
fi
fi
/bin/su -l $*
fi
- # relabel the console after returning.
- bash $FEISTY_MEOW_SCRIPTS/tty/label_terminal_with_infos.sh
+#NO! # relabel the console after returning.
+#NO! bash $FEISTY_MEOW_SCRIPTS/tty/label_terminal_with_infos.sh
+# fix this to set the old title back in place!
+
}
# sudo function wraps the normal sudo by ensuring we replace the terminal
source $FEISTY_MEOW_SCRIPTS/core/functions.sh
-pruned_host=$(echo $HOSTNAME | sed -e 's/^\([^\.]*\)\..*$/\1/')
-date_string=$(date +"%Y %b %e @ %T")
+# we only label the terminal anew if there's no saved title.
+
+#hmmm: how about putting that title back in place?
+# we currently do this manually in places, like ssh, which is dumb.
-user=$USER
-if [ -z "$user" ]; then
- # try snagging the windoze name.
- user=$USERNAME
-fi
-new_title="-- $user@$pruned_host -- [$date_string]"
+if [ -z "$PRIOR_TERMINAL_TITLE" ]; then
+ pruned_host=$(echo $HOSTNAME | sed -e 's/^\([^\.]*\)\..*$/\1/')
+ date_string=$(date +"%Y %b %e @ %T")
-bash "$FEISTY_MEOW_SCRIPTS/tty/set_term_title.sh" "$new_title"
+ user=$USER
+ if [ -z "$user" ]; then
+ # try snagging the windoze name.
+ user=$USERNAME
+ fi
+
+ new_title="-- $user@$pruned_host -- [$date_string]"
+
+ bash "$FEISTY_MEOW_SCRIPTS/tty/set_term_title.sh" "$new_title"
+fi