291eafd48544a1b5d8442f301caf15119386fbd9
[feisty_meow.git] / scripts / tty / label_terminal_with_infos.sh
1 #!/bin/bash
2
3 # this script makes a new title for the terminal window that matches the
4 # hostname and some other details.
5
6 source $FEISTY_MEOW_SCRIPTS/core/functions.sh
7
8 # we only label the terminal anew if there's no saved title.
9
10 #hmmm: how about putting that title back in place?
11 # we currently do this manually in places, like ssh, which is dumb.
12
13
14 if [ -z "$PRIOR_TERMINAL_TITLE" ]; then
15   pruned_host=$(echo $HOSTNAME | sed -e 's/^\([^\.]*\)\..*$/\1/')
16   date_string=$(date +"%Y %b %e @ %T")
17
18   user=$USER
19   if [ -z "$user" ]; then
20     # try snagging the windoze name.
21     user=$USERNAME
22   fi
23   
24   new_title="-- $user@$pruned_host -- [$date_string]"
25   
26   bash "$FEISTY_MEOW_SCRIPTS/tty/set_term_title.sh" "$new_title"
27 fi