From: Huck Boles Date: Sat, 24 Sep 2022 20:57:10 +0000 (-0500) Subject: zshmux creation X-Git-Tag: v1.0~14 X-Git-Url: https://git.huck.website/?a=commitdiff_plain;h=b9e952d91593016bf15883f2c19b8a7fc3fcaf0c;p=zshmux.git zshmux creation --- diff --git a/README.md b/README.md index 1a76528..817c180 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,10 @@ # zshmux -A super simple zsh plugin to attach to tmux sessions for new shells + +If a new shell is launched, *zshmux* quickly checks if there are any tmux sessions, or if the current shell is already in a tmux instance. +If you are not already in a tmux session *zshmux* will ask if you want to attach a currently running session, or make a new session in the shell. + +## How to use: +-Clone this repository + 'git clone https://github.com/huboles/zshmux' +-Source *zshmux* in your .zshrc + 'source /zshmux/zshmux.zsh' diff --git a/zshmux.zsh b/zshmux.zsh new file mode 100644 index 0000000..137333d --- /dev/null +++ b/zshmux.zsh @@ -0,0 +1,19 @@ +#!/bin/zsh + +if [[ -z $TMUX ]]; then + if tlist &> /dev/null ; then + printf 'Current tmux sessions:\n\n' + tlist + else + printf '\nNo tmux sessions active\n' + fi + printf '\n\tAttach session?: [name] (empty if none): ' + read response + if [ -n "$response" ]; then + if tlist | grep -q "$response"; then + tmux attach-session -t $response + else + tmux new-session -s $response + fi + fi +fi