You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.0 KiB
38 lines
1.0 KiB
#!/bin/bash
|
|
# vim: set filetype=sh:
|
|
|
|
# tmux configuration files are found in /tmux
|
|
export TMUX_CONF_DIR=${TMUX_CONF_DIR:-$__COMMON_CONFIGS/tmux}
|
|
# default status script just shows whether a reboot is needed
|
|
export TMUX_STATUS_SCRIPT=${TMUX_STATUS_SCRIPT:-"$TMUX_CONF_DIR/tmux.need-reboot.sh"}
|
|
|
|
function tmux_running() {
|
|
tmux -2 has-session -t "Nexus"
|
|
}
|
|
|
|
function tmux_init() {
|
|
tmux -2 new-session -d -s "Nexus" 'LC_ALL=C.UTF-8 fortune | cowsay -f eyes -W "$COLUMNS"; exec "$SHELL" -i'
|
|
}
|
|
|
|
function go_tmux ()
|
|
{
|
|
if [[ "$TERM" == screen* ]] || "$TERM" == tmux* ]]; then
|
|
echo "You're already inside a tmux instance!"
|
|
return 1;
|
|
fi
|
|
echo "Starting tmux..."
|
|
tmux_running || tmux_init || return 1
|
|
if [[ $1 == "-x" ]]; then
|
|
exec tmux -2 attach-session -t "Nexus" || return 1
|
|
else
|
|
tmux -2 attach-session -t "Nexus" || return 1
|
|
fi
|
|
}
|
|
|
|
function auto_tmux ()
|
|
{
|
|
if [[ -t 1 ]] && [[ -t 0 ]] && [[ -t 2 ]] && [[ "$TERM" != screen* ]] && [[ -z "$ALREADY_TRIED_STARTING_TMUX" ]]; then
|
|
ALREADY_TRIED_STARTING_TMUX=true
|
|
go_tmux -x
|
|
fi
|
|
}
|
|
|