Skip to content

Instantly share code, notes, and snippets.

@adrianparvino
Last active August 31, 2019 02:15
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 adrianparvino/a213d71d4a8562d4d2ab5cdbb1902850 to your computer and use it in GitHub Desktop.
Save adrianparvino/a213d71d4a8562d4d2ab5cdbb1902850 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
SEP=
for ((i = 3 ; i <= $# ; i++)); do
if [ "${!i}" != "--" ]; then continue; fi
SEP="$i"
break
done
FLAGs=$((SEP - 2 - 2))
MACHINE=$((SEP - 1))
exec nixops ssh "${@:1:2}" "${!MACHINE}" "${@:3:$FLAGs}" "${@:$SEP}"
# Requires mosh/mosh-client in PATH
let
nixops-mosh = pkgs.writeScriptBin "nixops-mosh" ''
#!${pkgs.stdenv.shell}
exec ${mosh}/bin/mosh --experimental-remote-ip=remote --ssh="${nixops-mosh-adaptor}/bin/nixops-mosh-adaptor -d $1" $2
'';
nixops-mosh-adaptor = pkgs.writeScriptBin "nixops-mosh-adaptor" ''
#!${pkgs.stdenv.shell}
SEP=
for ((i = 3 ; i <= $# ; i++)); do
if [ "''${!i}" != "--" ]; then continue; fi
SEP="$i"
break
done
FLAGs=$((SEP - 2 - 2))
MACHINE=$((SEP - 1))
exec ${nixops}/bin/nixops ssh "''${@:1:2}" "''${!MACHINE}" "''${@:3:$FLAGs}" "''${@:$SEP}"
'';
in nixops-mosh
mosh --experimental-remote-ip=remote --ssh='./nixops-mosh-adaptor.sh -d deployment' machine
nixops-mosh deployment machine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment