Skip to content

Instantly share code, notes, and snippets.

@broskisworld
Created October 20, 2022 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save broskisworld/26d5a452c526e2fca279d95cb01dd0da to your computer and use it in GitHub Desktop.
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
# 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