Add port forwarding functions for web dev

So we can forward a port on localhost to an Omaterm
This commit is contained in:
David Heinemeier Hansson
2026-02-10 12:00:04 +01:00
parent 527819b750
commit 07ede07193

View File

@@ -87,3 +87,18 @@ img2png() {
-define png:exclude-chunk=all \
"${img%.*}-optimized.png"
}
# SSH Port Forwarding Functions
fip() {
[[ -z "$1" || -z "$2" ]] && echo "Usage: fip <port> <host>" && return 1
ssh -f -N -L "$1:localhost:$1" "$2" && echo "Forwarding localhost:$1 -> $2:$1"
}
dip() {
[[ -z "$1" ]] && echo "Usage: dip <port>" && return 1
pkill -f "ssh.*-L $1:localhost:$1" && echo "Stopped forwarding port $1" || echo "No forwarding on port $1"
}
lip() {
pgrep -af "ssh.*-L [0-9]+:localhost:[0-9]+" || echo "No active forwards"
}