mirror of
https://github.com/ohmybash/oh-my-bash.git
synced 2024-05-11 05:55:37 +00:00
30 lines
649 B
Bash
30 lines
649 B
Bash
![]() |
# @chopnico 2021
|
||
|
#
|
||
|
# tmux-autoattach.plugin.sh
|
||
|
#
|
||
|
# A tmux plugin that will automatically attach itself to a bash session.
|
||
|
|
||
|
[ -z "$OSH_PLUGIN_TMUX_AUTOATTACH_BEHAVIOR" ] && export OSH_PLUGIN_TMUX_AUTOATTACH_BEHAVIOR="detach"
|
||
|
|
||
|
_osh_plugin_tmux_autoattach_exit() {
|
||
|
[ -z "$TMUX" ] && tmux -2u new -A && exit
|
||
|
}
|
||
|
|
||
|
_osh_plugin_tmux_autoattach_detach() {
|
||
|
[ -z "$TMUX" ] && tmux -2u new -A
|
||
|
}
|
||
|
|
||
|
if [ "$DISPLAY" ] || [ "$WAYLAND_DISPLAY" ]; then
|
||
|
case "$OSH_PLUGIN_TMUX_AUTOATTACH_BEHAVIOR" in
|
||
|
"exit")
|
||
|
_osh_plugin_tmux_autoattach_exit
|
||
|
;;
|
||
|
"detach")
|
||
|
_osh_plugin_tmux_autoattach_detach
|
||
|
;;
|
||
|
*)
|
||
|
_osh_plugin_tmux_autoattach_detach
|
||
|
;;
|
||
|
esac
|
||
|
fi
|