Created
November 27, 2015 17:25
-
-
Save jamesandariese/85cc1340f345ce047dc0 to your computer and use it in GitHub Desktop.
mosh-clean: cleanup dangling mosh servers
This file contains hidden or 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/sh | |
# This kills all mosh-servers not directly the parent of your shell. | |
# This will not work entirely correctly if your shell isn't being run directly by | |
# `mosh-server`. | |
# This next line can either go in your bashrc or the file can be sourced by it. | |
alias mosh-clean='(ps jp $$ |tail -n +2; ps x |tail -n +2) | awk '"'"'$1 != skippid && rest && $5 ~ /^mosh-server$/ {print $1} !rest {rest=1; skippid = $1}'"'"' | xargs -rt kill' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment