From 6fd35bc232cdbed0bf37cfaf337af170b4b17d10 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Tue, 12 Nov 2019 16:39:31 -0600 Subject: [PATCH] More handy scripts --- bin/devtunnel | 11 +++++++++++ bin/fsw | 5 +++++ bin/remote | 22 +++++++--------------- de/x/resources | 2 ++ 4 files changed, 25 insertions(+), 15 deletions(-) create mode 100755 bin/devtunnel diff --git a/bin/devtunnel b/bin/devtunnel new file mode 100755 index 0000000..7cb459e --- /dev/null +++ b/bin/devtunnel @@ -0,0 +1,11 @@ +#!/usr/bin/env moon +arg_spec = { + {"target", "REMOTE_MACHINE", "remote"} + {"fwd", "FORWARD_PORTS", "1313,3000,4800:8000,8080,1234,40080:80,40443:443"} + {"sargs", "SSH_ARGS", "-XY"} +} +args = {v[1], os.getenv(v[2]) or arg[i] or v[3] for i, v in ipairs(arg_spec)} +ports = {a, (if b == "" then a else b) for a, b in args.fwd\gmatch "(%d+):?(%d*),?"} +pargs = table.concat ["-L #{k}:localhost:#{v}" for k,v in pairs ports], " " +for k,v in pairs ports do print "Forwarding localhost:#{k} to #{args.target}:#{v}" +os.execute "ssh -N #{args.target} #{pargs} #{args.sargs}" diff --git a/bin/fsw b/bin/fsw index 73eb43d..ca0541b 100755 --- a/bin/fsw +++ b/bin/fsw @@ -49,6 +49,11 @@ FSW_EVENTS="${FSW_EVENTS:-close_write}" SHELL_COMMAND="${1}"; shift FILTER="${1}"; shift DIRS=("${1:-.}"); shift +if [[ -e $FILTER ]]; then + # TODO: this is a sad hack/workaround + echo "It looks like your filter is an actual file. I'll just watch that for you." + DIRS=("${FILTER}") +fi while [[ ! -z $1 ]]; do DIRS+=("$1"); shift done diff --git a/bin/remote b/bin/remote index 48cff38..8de7aef 100755 --- a/bin/remote +++ b/bin/remote @@ -1,17 +1,9 @@ #!/usr/bin/env moon - -require('fun')! - -garg = (v, i) -> os.getenv(v[1]) or arg[i] or v[2] -target, fwd, mpr, sargs, margs = unpack totable map garg, iter { - {"REMOTE_MACHINE", "remote"} - {"SSH_FORWARD_PORTS", "1313,3000,8000,8080,1234,40080:80,40443:443"} - {"MOSH_PORT_RANGE", "60000:61000"} - {"SSH_ARGS", "-XY"} - {"MOSH_ARGS", ""} +arg_spec = { + {"target", "REMOTE_MACHINE", "remote"} + {"mpr", "MOSH_PORT_RANGE", "60000:61000"} + {"sargs", "SSH_ARGS", "-XY"} + {"margs", "MOSH_ARGS", ""} } - -sfwd = fwd\gsub "(%d+):?(%d*),?", (p, mp) -> - "-L #{p}:localhost:#{if mp == "" then p else mp} " - -os.execute "mosh -p '#{mpr}' '#{target}' --ssh='ssh #{sfwd} #{sargs}' #{margs}" +args = {v[1], os.getenv(v[2]) or arg[i] or v[3] for i, v in ipairs(arg_spec)} +os.execute "mosh -p '#{args.mpr}' '#{args.target}' --ssh='ssh #{args.sargs}' #{args.margs}" diff --git a/de/x/resources b/de/x/resources index a0a0d48..7ac0b56 100755 --- a/de/x/resources +++ b/de/x/resources @@ -17,6 +17,8 @@ ## Set fonts in "$HOME/.Xresources.env" URxvt.font: xft:Iosevka Term:pixelsize=14,xft:Noto Emoji,xft:Font Awesome 5 Free:pixelsize=14,xft:FreeSans:pixelsize=14 URxvt.faceName: xft:Iosevka Term:pixelsize=14,xft:Font Awesome 5 Free:pixelsize=14,xft:FreeSans:pixelsize=14 +Emacs.font: Iosevka Term +Emacs.faceName: Iosevka Term # URxvt.transparent: true # URxvt.shading: 70 URxvt.letterSpace: 0