eb590dae66f1e3931f417264045d45ddeafd1ff2
[profile.git] / opt / bin / ktmux
1 #!/bin/bash
2
3 tmux=tmux
4 tmux_opts=
5 session_opts=
6 while getopts ":T:n:s:t:" opt; do
7   case $opt in
8     T) tmux="$OPTARG";;
9     n|s|t) session_opts="$session_opts -$opt $OPTARG";;
10   esac
11 done
12 shift $((OPTIND-1))
13
14 if [ -z "$KRB5CCNAME" ]; then
15   krb5ccname="$KRB5CCNAME"
16   [ -z "$krb5ccname" ] && krb5ccname=FILE:${TMPDIR:-/tmp}/krb5cc_${UID}_ktmux_$$
17   export KRB5CCNAME="$krb5ccname"
18 fi
19 klist -s || kinit
20
21 exec $tmux ${tmux_opts## } new-session ${session_opts## } -d ';' set-environment KRB5CCNAME "$KRB5CCNAME" ';' attach ';' run-shell ktmux_helper