summaryrefslogtreecommitdiff
path: root/plugins/tmux/tmux.plugin.zsh
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2023-11-04 18:38:46 -0700
committerTuowen Zhao <ztuowen@gmail.com>2023-11-04 18:38:46 -0700
commit4d908094fdc2a0c0e9a0a072eba213fab7adef43 (patch)
tree7c17e70bcdeebbe96c84d849bdf17882007480d8 /plugins/tmux/tmux.plugin.zsh
parent4b0bbc0b263a150eb9a9b59f196914629be06a9b (diff)
parent632ed413a9ce62747ded83d7736491b081be4b49 (diff)
downloadzsh-4d908094fdc2a0c0e9a0a072eba213fab7adef43.tar.gz
zsh-4d908094fdc2a0c0e9a0a072eba213fab7adef43.tar.bz2
zsh-4d908094fdc2a0c0e9a0a072eba213fab7adef43.zip
Merge remote-tracking branch 'github/master'HEADmaster
Diffstat (limited to 'plugins/tmux/tmux.plugin.zsh')
-rw-r--r--plugins/tmux/tmux.plugin.zsh24
1 files changed, 21 insertions, 3 deletions
diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh
index 311c2e6a9..72cdd4818 100644
--- a/plugins/tmux/tmux.plugin.zsh
+++ b/plugins/tmux/tmux.plugin.zsh
@@ -26,12 +26,17 @@ fi
# systems without the proper terminfo
: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color}
# Set the configuration path
-: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
+if [[ -e $HOME/.tmux.conf ]]; then
+ : ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
+elif [[ -e ${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf ]]; then
+ : ${ZSH_TMUX_CONFIG:=${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf}
+else
+ : ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
+fi
# Set -u option to support unicode
: ${ZSH_TMUX_UNICODE:=false}
# ALIASES
-
alias ta='tmux attach -t'
alias tad='tmux attach -d -t'
alias ts='tmux new-session -s'
@@ -103,8 +108,21 @@ 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" ]]; then
+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.
if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]; then
export ZSH_TMUX_AUTOSTARTED=true