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.
40 lines
1.0 KiB
40 lines
1.0 KiB
5 years ago
|
#!/bin/bash
|
||
|
# vim: set filetype=sh:
|
||
|
|
||
3 years ago
|
# tmux configuration files are found in /tmux
|
||
|
export TMUX_CONF_DIR=${TMUX_CONF_DIR:-$__COMMON_CONFIGS/tmux}
|
||
5 years ago
|
# default status script just shows whether a reboot is needed
|
||
3 years ago
|
export TMUX_STATUS_SCRIPT=${TMUX_STATUS_SCRIPT:-"$TMUX_CONF_DIR/tmux.need-reboot.sh"}
|
||
5 years ago
|
|
||
3 years ago
|
function tmux_running() {
|
||
|
tmux -2 has-session -t "Nexus"
|
||
5 years ago
|
}
|
||
|
|
||
3 years ago
|
function tmux_init() {
|
||
|
tmux -2 new-session -d -s "Nexus" -n "Misc."
|
||
|
tmux -2 new-window -d -t "Nexus:0" -n "Monitor" "htop"
|
||
5 years ago
|
}
|
||
|
|
||
|
function go_tmux ()
|
||
|
{
|
||
|
if [[ "$TERM" == screen* ]]; then
|
||
3 years ago
|
echo "You're already inside a tmux instance!"
|
||
5 years ago
|
return 1;
|
||
|
fi
|
||
|
echo "Starting tmux..."
|
||
3 years ago
|
tmux_running || tmux_init || return 1
|
||
5 years ago
|
if [[ $1 == "-x" ]]; then
|
||
3 years ago
|
exec tmux -2 attach-session -t "Nexus" || return 1
|
||
5 years ago
|
else
|
||
3 years ago
|
tmux -2 attach-session -t "Nexus" || return 1
|
||
5 years ago
|
fi
|
||
|
}
|
||
|
|
||
|
function auto_tmux ()
|
||
|
{
|
||
5 years ago
|
if [[ -t 1 ]] && [[ -t 0 ]] && [[ -t 2 ]] && [[ "$TERM" != screen* ]] && [[ -z "$ALREADY_TRIED_STARTING_TMUX" ]]; then
|
||
5 years ago
|
ALREADY_TRIED_STARTING_TMUX=true
|
||
3 years ago
|
go_tmux -x
|
||
5 years ago
|
fi
|
||
|
}
|