Last active
December 18, 2020 08:28
-
-
Save airglow923/246f06c681a2cbe6042a287d3de2be11 to your computer and use it in GitHub Desktop.
Shell commands to kill detached (unattached) tmux sessions
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
#!/bin/bash | |
TMUX_UNATTACHED=$(tmux ls | grep -E -v '\(attached\)$') | |
while read session; do | |
tmux kill-session -t "${line%%:*}" | |
done <<< $TMUX_UNATTACHED |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternatively, append the following lines to the system shell configuration file (i.e..~/.bashrc, ~/.zshrc, etc.):
and run
source ~/.bashrc
to refresh the current terminal session. Change.bashrc
if you are using different shell config files.Then, enter
tmux-kill-unattached
to execute the function.This way is preferred since the first method requires users to specify the path to the
tmux-kill-unattached.sh
.