summary refs log tree commit diff
path: root/home
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-10-27 09:44:45 -0400
committerJune McEnroe <june@causal.agency>2020-10-27 09:44:45 -0400
commit07db07a96f1c13fc26d508dbdb747e9d412fec84 (patch)
tree954b33808e60cece4be8c736a85eaf97316f4b8e /home
parentUse mandoc -T utf8 for text. (diff)
downloadsrc-07db07a96f1c13fc26d508dbdb747e9d412fec84.tar.gz
src-07db07a96f1c13fc26d508dbdb747e9d412fec84.zip
Allow cd host:path over ssh
Requires AcceptEnv SSH_CD in the remote sshd_config.
Diffstat (limited to '')
-rw-r--r--home/.shrc6
1 files changed, 6 insertions, 0 deletions
diff --git a/home/.shrc b/home/.shrc
index feb679ef..df1c8b26 100644
--- a/home/.shrc
+++ b/home/.shrc
@@ -20,12 +20,18 @@ type doas >/dev/null 2>&1 && alias sudo=doas
 cd() {
 	if [ $# -eq 0 ]; then
 		builtin cd
+	elif [ "${1%%:*}" != "$1" ]; then
+		ssh -o "SetEnv SSH_CD=${1#*:}" "${1%%:*}"
 	elif [ -e "$1" -a ! -d "$1" ]; then
 		builtin cd "${1%/*}" && $EDITOR "${1##*/}"
 	else
 		builtin cd "$@"
 	fi
 }
+if [ -n "${SSH_CD:-}" ]; then
+	cd "${SSH_CD}"
+	unset SSH_CD
+fi
 
 PS0=$'\n'
 PS1='\$ '