Skip to content

Instantly share code, notes, and snippets.

@mgedmin
Created May 31, 2012 17:16
Show Gist options
  • Save mgedmin/2844839 to your computer and use it in GitHub Desktop.
Save mgedmin/2844839 to your computer and use it in GitHub Desktop.
.bashrc snippet to remind me about running screen/tmux sessions
# check for screen sessions
if [ -d /var/run/screen/S-$USER/ ]; then
n=$(find /var/run/screen/S-$USER/ -type p|wc -l)
if [ $n -gt 0 ]; then
test x"$TERM" = xscreen && test -n "$WINDOW" \
&& echo "You have $n active screen sessions (and this is one of them)." \
|| echo "You have $n active screen sessions."
fi
fi
# check for tmux sessions
if [ -x /usr/bin/tmux ]; then
n=$(tmux list-sessions 2>/dev/null|wc -l)
if [ $n -gt 0 ]; then
test x"$TERM" = xscreen && test -n "$TMUX" \
&& echo "You have $n active tmux sessions (and this is one of them)." \
|| echo "You have $n active tmux sessions."
fi
fi
@mgedmin
Copy link
Author

mgedmin commented Dec 17, 2012

Now maintained at https://github.com/mgedmin/dotfiles/blob/master/bashrc.screen (but I don't anticipate changes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment