tasty renamings
[feisty_meow.git] / customize / fred / scripts / ssh.sh
1 #!/bin/bash
2
3 # wraps our calling the secure shell and lets us pick our credentials.
4
5 source "$FEISTY_MEOW_LOADING_DOCK/custom/scripts/pick_credentials.sh"
6
7 # save the former terminal title if we're running in X with xterm.
8 prior_title=
9 which xprop &>/dev/null
10 if [ $? -eq 0 ]; then
11   if [[ "$TERM" =~ .*"xterm".* ]]; then
12     prior_title="$(xprop -id $WINDOWID | perl -nle 'print $1 if /^WM_NAME.+= \"(.*)\"$/')"
13   fi
14 fi
15
16 # force the TERM variable to a more generic version for other side.
17 # we don't want the remote side still thinking it's running xterm.
18 export TERM=linux
19
20 #hmmm: it would be good to set an interrupt handler here and
21 #      trap ctrl-c, since otherwise we are getting exited from and losing a chance
22 #      to reset the terminal title.  this actually happens a lot, since some X11
23 #      or other background process is left running and the ssh never actually quits,
24 #      forcing one to hit ctrl-c.
25
26 if [ ! -z "$keyfile" ]; then
27   \ssh -i "$keyfile" -X -C $*
28 #-c blowfish-cbc 
29 else
30   \ssh -X -C $*
31 #-c blowfish-cbc 
32 fi
33
34 if [ $? -eq 0 ]; then
35   # we don't want to emit anything extra if this is being driven by git.
36   if [ -z "$(echo $* | grep git)" ]; then
37     # re-run the terminal labeller after coming back from ssh.
38     # we check the exit value because we don't want to update this for a failed connection.
39     if [ -z "$prior_title" ]; then
40 #echo prior title nil new label
41       bash $FEISTY_MEOW_SCRIPTS/tty/label_terminal_with_infos.sh
42     else
43 #echo "using old prior title of '$prior_title'"
44       bash $FEISTY_MEOW_SCRIPTS/tty/set_term_title.sh "$prior_title"
45     fi
46   fi
47 fi
48
49