Skip to content

Instantly share code, notes, and snippets.

@jamesandariese
Created November 27, 2015 17:25
Show Gist options
  • Save jamesandariese/85cc1340f345ce047dc0 to your computer and use it in GitHub Desktop.
Save jamesandariese/85cc1340f345ce047dc0 to your computer and use it in GitHub Desktop.
mosh-clean: cleanup dangling mosh servers
#!/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