Created
January 25, 2022 09:16
-
-
Save svanellewee/2d5de20b0cd16f0433af95edbf45b01e to your computer and use it in GitHub Desktop.
Connect to the same tmux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pop this in your bashrc | |
if [[ -z "$TMUX" ]] # hey bash, are you inside a tmux already? Then ignore! | |
then | |
# if bash is not currently in a tmux session, look for the first.. | |
first_session=$(tmux ls 2>/dev/null|grep -Po '\K[0-9]+?(?=\: )') | |
if [[ ! -z "${first_session}" ]] | |
then | |
# oh you found a session! Attach to that badboy | |
tmux attach-session -t "${first_session}" | |
else | |
# Not running inside tmux, and no current session. MAKE ONE! | |
tmux | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment