laggardkernel / zsh-tmux

Auto start/attach tmux session with consistent session names

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

zsh-tmux

License: MIT

Auto start a tmux session once shell is launched. Auto name the session as directory-hash to keeps a consistent name for sessions created in the same directories, which means we could auto attach to an existing session.

Features

  • Creating/Attaching sessions automatically on shell run
  • Consistent session name for the same directory
  • Options to
    • Disable auto session creating/attaching
    • Kill shell automatically once u detach from a tmux session
    • Custom environment variable TERM for tmux commands

Installation

Zinit

The only ZSH plugin manager solves the time-consuming init for nvm, nodenv, pyenv, rvm, rbenv, thefuck, fasd, etc, with its amazing async Turbo Mode.

# add it into your .zshrc
zinit ice pick'init.zsh'
zinit light laggardkernel/zsh-tmux

Update the plugin with

$ zinit update laggardkernel/zsh-tmux

Prezto

The only framework does optimizations in plugins with sophisticated coding skill:

mkdir -p ${ZDOTDIR:-$HOME}/.zprezto/contrib &>/dev/null
git clone git@github.com:laggardkernel/zsh-tmux.git ${ZDOTDIR:-$HOME}/.zprezto/contrib/zsh-tmux

# or use HTTPS instead
git clone https://github.com/laggardkernel/zsh-tmux.git ${ZDOTDIR:-$HOME}/.zprezto/contrib/zsh-tmux

Settings

Auto Start

Automatically attach to an existing tmux session, or create a session once the plugin is enabled. Disable auto attaching/creating with

# global setting
NO_AUTO_TMUX=1 # enabled by default

# setting for local terminal only
zstyle ':prezto:module:tmux:auto-start' local 'no' # default 'yes'

# setting for remote terminal only
zstyle ':prezto:module:tmux:auto-start' remote 'no' # default 'no'

TERM Variable

Custom environment variable TERM for tmux commands.

zstyle ":prezto:module:tmux:term" with_256color "xterm-256color" # default screen-256
zstyle ":prezto:module:tmux:term" without_256color "xtermr" # default screen

iTerm Integration

Enable auto session creating/attaching support for Tmux CONTROL MODE in iTerm with

zstyle ":prezto:module:tmux:iterm" integrate "yes" # default 'no'

Todo

  • Length customization for hash suffix in session name
  • Setting to kill shell when detach from a session
  • Setting to kill shell when exit from a session

License

The MIT License (MIT)

Copyright (c) 2021 laggardkernel

About

Auto start/attach tmux session with consistent session names

License:MIT License


Languages

Language:Shell 100.0%