Skip to content

Instantly share code, notes, and snippets.

@tribut
Created April 10, 2013 09:03
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 tribut/5353055 to your computer and use it in GitHub Desktop.
Save tribut/5353055 to your computer and use it in GitHub Desktop.
call mosh_pc.sh for list of hosts, mosh otherwise
#!/bin/bash
# ########################################################## #
# wrapper for mosh that will call mosh_pc.sh for a list of #
# host and mosh otherwise. see mosh_pc.sh why you might want #
# this. #
# ########################################################## #
# >> modify this
indirect_access=(asterix obelix idefix)
# <<
# this should be easier...
function contains() {
for value in "${indirect_access[@]}"; do
if [ "$value" == "$1" ]; then
return 0
fi
done
return 1
}
# get target hostname from potentially more complex commandline
hostname="`getopt -q -o'-' -- $@ | cut -d\' -f2`"
if contains "$hostname"; then
mosh_pc.sh "$@"
else
mosh "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment