Allow specifying paths to Kerberos helpers.
[profile.git] / opt / bin / ktmux
1 #!/bin/bash
2 #
3 # ktmux: Start tmux and ktmux_helper.
4 # Usage: ktmux [options]
5 # Options: -I <path>   Pass path to kinit through to ktmux_helper.
6 #          -L <path>   Pass path to klist through to ktmux_helper.
7 #          -R <path>   Pass path to krenew through to ktmux_helper.
8 #          -T <path>   Path to tmux.
9 #          -n <name>   Window name for new tmux session.
10 #          -s <name>   Session name for new tmux session.
11 #          -t <name>   Target session name for new tmux session.
12 #
13
14 tmux=tmux
15 helper_opts=
16 tmux_opts=
17 session_opts=
18 while getopts ":I:L:R:T:n:s:t:" opt; do
19   case $opt in
20     I|L|R) helper_opts="$helper_opts -$opt $OPTARG";;
21     T) tmux="$OPTARG";;
22     n|s|t) session_opts="$session_opts -$opt $OPTARG";;
23   esac
24 done
25 shift $((OPTIND-1))
26
27 if [ -z "$KRB5CCNAME" ]; then
28   krb5ccname="$KRB5CCNAME"
29   [ -z "$krb5ccname" ] && krb5ccname=FILE:${TMPDIR:-/tmp}/krb5cc_${UID}_ktmux_$$
30   export KRB5CCNAME="$krb5ccname"
31 fi
32 klist -s || kinit
33
34 exec $tmux ${tmux_opts## } new-session ${session_opts## } -d ';' set-environment KRB5CCNAME "$KRB5CCNAME" ';' attach ';' run-shell "ktmux_helper ${helper_opts## }"