Fix fip function on zsh

This commit is contained in:
Paul Wagner
2026-07-19 17:48:17 -07:00
committed by David Heinemeier Hansson
parent d4d1b518e0
commit 26bca7d834
+3 -3
View File
@@ -1,17 +1,17 @@
# SSH Port Forwarding Functions
fip() {
(( $# < 2 )) && echo "Usage: fip <host> <port1> [port2] ..." && return 1
local host="$1"
local host="${1}"
shift
for port in "$@"; do
ssh -f -N -L "$port:localhost:$port" "$host" && echo "Forwarding localhost:$port -> $host:$port"
ssh -f -N -L "${port}:localhost:${port}" "${host}" && echo "Forwarding localhost:${port} -> ${host}:${port}"
done
}
dip() {
(( $# == 0 )) && echo "Usage: dip <port1> [port2] ..." && return 1
for port in "$@"; do
pkill -f "ssh.*-L $port:localhost:$port" && echo "Stopped forwarding port $port" || echo "No forwarding on port $port"
pkill -f "ssh.*-L ${port}:localhost:${port}" && echo "Stopped forwarding port ${port}" || echo "No forwarding on port ${port}"
done
}