9dc24198cd70b803eb9aa144d9af7ebbb6de75a5
[feisty_meow.git] / customizing / 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_GENERATED/custom/scripts/pick_credentials.sh"
6
7 # save the former terminal title if we're running in X with xterm.
8 prior_title=
9 if [ "$TERM" == "xterm" ]; then
10   prior_title="$(xprop -id $WINDOWID | perl -nle 'print $1 if /^WM_NAME.+= \"(.*)\"$/')"
11 fi
12
13 # force the TERM variable to a more generic version for other side.
14 # we don't want the remote side still thinking it's running xterm.
15 export TERM=linux
16
17 if [ ! -z "$keyfile" ]; then
18   \ssh -i "$keyfile" -X -C -c blowfish-cbc $*
19 else
20   \ssh -X -C -c blowfish-cbc $*
21 fi
22
23 if [ $? -eq 0 ]; then
24   # we don't want to emit anything extra if this is being driven by git.
25   if [ -z "$(echo $* | grep git)" ]; then
26     # re-run the terminal labeller after coming back from ssh.
27     # we check the exit value because we don't want to update this for a failed connection.
28     if [ -z "$prior_title" ]; then
29       bash $FEISTY_MEOW_SCRIPTS/tty/label_terminal_with_infos.sh
30     else
31       bash $FEISTY_MEOW_SCRIPTS/tty/set_term_title.sh "$prior_title"
32     fi
33   fi
34 fi
35
36