commit eceaa931bb00ce63afde7618b4102fb5ee432374 parent 32980791b1e51c6aba056837656bcfd3bc81a51e Author: Janis Pagel <janis.pagel@ims.uni-stuttgart.de> Date: Tue, 10 Jul 2018 11:32:13 +0200 Add better tmux handling Tmux now creates new sessions automatically when a terminal is started or attaches to an existing session. Diffstat:
M | zsh/zshrc | | | 12 | ++++++++++-- |
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/zsh/zshrc b/zsh/zshrc @@ -93,8 +93,16 @@ fi ##### Misc ###### ################# -# If tmux is running -if [ -n "$TMUX" ]; then +# TMUX +if [[ -z "$TMUX" ]] ;then + ID="$( tmux ls | grep -vm1 attached | cut -d: -f1 )" # get the id of a deattached session + if [[ -z "$ID" ]] ;then # if not available create a new one + tmux new-session + else + tmux attach-session -t "$ID" # if available attach to it + fi +fi +if [ -n "$TMUX" ]; then # If tmux is running # create a global per-pane variable that holds the pane's PWD export PS1=$PS1'$( [ -n $TMUX ] && tmux setenv -g TMUX_PWD_$(tmux display -p "#D" | tr -d %) $PWD)' fi