Created
October 20, 2022 15:13
-
-
Save broskisworld/26d5a452c526e2fca279d95cb01dd0da to your computer and use it in GitHub Desktop.
A quick function you can add to your .zshrc or .bashrc to close all screens with a certain name, even if multiple screens exist with the same name
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
# killscreens() | |
# close alls screens with name | |
# based on answer by joschi from question here https://unix.stackexchange.com/questions/20435/killing-multiple-gnu-screen-sessions-with-the-same-name | |
# | |
# [ USAGE ] | |
# killscreens <screen-name> Kill all screens with name | |
# killscreens -h Displays help menu | |
killscreens() { | |
if [[ "$1" == "" || "$1" == "-h" || "$1" == "--help" || "$1" == "help" || "$2" != "" ]]; then | |
echo "Usage: killscreens <screen-name>" | |
return | |
fi | |
for session in $(screen -ls | grep -o "[0-9]*\.$1"); do screen -S "${session}" -X quit; done | |
echo "killed all screens with name $1." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment