From 2b1303a728afc285cc13a6710de128a050500f1e Mon Sep 17 00:00:00 2001 From: n0tr00t <106423923+0x020B@users.noreply.github.com> Date: Sun, 3 Sep 2023 15:38:32 +0000 Subject: feat(tmux): allow all standard config files (#11103) Closes #11803 Co-authored-by: n0tr00t <106423923+n0tr00teuorg@users.noreply.github.com> --- plugins/tmux/README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'plugins/tmux/README.md') diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md index 7348f77c9..0f8473daf 100644 --- a/plugins/tmux/README.md +++ b/plugins/tmux/README.md @@ -28,16 +28,16 @@ The plugin also supports the following: ## Configuration Variables -| Variable | Description | -| ----------------------------------- | ----------------------------------------------------------------------------- | -| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) | -| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) | -| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) | -| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) | -| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support | -| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) | -| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) | -| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` | -| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`) | -| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode | -| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled | +| Variable | Description | +| ----------------------------------- | ------------------------------------------------------------------------------------------- | +| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) | +| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) | +| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) | +| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) | +| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support | +| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) | +| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) | +| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` | +| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`, `$XDG_CONFIG_HOME/tmux/tmux.conf`) | +| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode | +| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled | -- cgit v1.2.3-70-g09d2 From 104041a018dc9a3eb74f93815192dba4c9386e1a Mon Sep 17 00:00:00 2001 From: Peat Bakke Date: Thu, 19 Oct 2023 02:49:38 -0700 Subject: feat(tmux): add `tds` alias for directory sessions (#11987) --- plugins/tmux/README.md | 1 + plugins/tmux/tmux.plugin.zsh | 13 +++++++++++++ 2 files changed, 14 insertions(+) (limited to 'plugins/tmux/README.md') diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md index 0f8473daf..b4516ef26 100644 --- a/plugins/tmux/README.md +++ b/plugins/tmux/README.md @@ -25,6 +25,7 @@ The plugin also supports the following: | `tkss` | tmux kill-session -t | Terminate named running tmux session | | `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session | | `tmuxconf` | `$EDITOR $ZSH_TMUX_CONFIG` | Open .tmux.conf file with an editor | +| `tds` | `_tmux_directory_session` | Creates or attaches to a session for the current path | ## Configuration Variables diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index 6ed91c447..72cdd4818 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -108,6 +108,19 @@ compdef _tmux _zsh_tmux_plugin_run # Alias tmux to our wrapper function. alias tmux=_zsh_tmux_plugin_run +function _tmux_directory_session() { + # current directory without leading path + local dir=${PWD##*/} + # md5 hash for the full working directory path + local md5=$(printf '%s' "$PWD" | md5sum | cut -d ' ' -f 1) + # human friendly unique session name for this directory + local session_name="${dir}-${md5:0:6}" + # create or attach to the session + tmux new -As "$session_name" +} + +alias tds=_tmux_directory_session + # Autostart if not already in tmux and enabled. if [[ -z "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" && -z "$INSIDE_EMACS" && -z "$EMACS" && -z "$VIM" && -z "$INTELLIJ_ENVIRONMENT_READER" ]]; then # Actually don't autostart if we already did and multiple autostarts are disabled. -- cgit v1.2.3-70-g09d2