summary refs log tree commit diff
path: root/home
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-05 10:10:13 -0500
committerJune McEnroe <june@causal.agency>2019-12-05 10:10:13 -0500
commit8a81d1527238209b7282a7887bf801e0b4830bab (patch)
treea83869332fe68fb30129825fbbe3049a52cf58c8 /home
parentAdd The Fifth Season (diff)
downloadsrc-8a81d1527238209b7282a7887bf801e0b4830bab.tar.gz
src-8a81d1527238209b7282a7887bf801e0b4830bab.zip
Allow cd-ing into a file
Diffstat (limited to 'home')
-rw-r--r--home/.shrc10
1 files changed, 10 insertions, 0 deletions
diff --git a/home/.shrc b/home/.shrc
index 45b2fe62..b864018b 100644
--- a/home/.shrc
+++ b/home/.shrc
@@ -18,6 +18,16 @@ alias rand='openssl rand -base64 33'
 alias private='eval "$(gpg -d ~/.private)"'
 bman() { ssh ${freebsd:-monday} man "$@" | sh -c "$MANPAGER"; }
 
+cd() {
+	if [ $# -eq 0 ]; then
+		builtin cd
+	elif [ -e "$1" -a ! -d "$1" ]; then
+		builtin cd "${1%/*}" && $EDITOR "${1##*/}"
+	else
+		builtin cd "$@"
+	fi
+}
+
 PS0=$'\n'
 PS1='\$ '
 RPS1="\? ${SSH_CLIENT:+\h:}\w"