Skip to content

Instantly share code, notes, and snippets.

@paranoidjk
Created December 31, 2015 05:42
Show Gist options
  • Save paranoidjk/3c438cae9c8c34eac536 to your computer and use it in GitHub Desktop.
Save paranoidjk/3c438cae9c8c34eac536 to your computer and use it in GitHub Desktop.
auto open exist tmux session when open bash or zsh etc
tmux_init()
{
tmux new-session -s "kumu" -d -n "local" # 开启一个会话
tmux new-window -n "other" # 开启一个窗口
tmux split-window -h # 开启一个竖屏
tmux split-window -v "top" # 开启一个横屏,并执行top命令
tmux -2 attach-session -d # tmux -2强制启用256color,连接已开启的tmux
}
# 判断是否已有开启的tmux会话,没有则开启
if which tmux 2>&1 >/dev/null; then
test -z "$TMUX" && (tmux attach || tmux_init)
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment