From bd1e968f6f760f1f803fb3555d460ffd7e6e33a6 Mon Sep 17 00:00:00 2001 From: druckdev Date: Mon, 25 Jan 2021 10:20:55 +0100 Subject: [PATCH] zsh:funcs:cd: Recognize ls suffix in paths --- .config/zsh/zshrc.d/40-functions.zsh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.config/zsh/zshrc.d/40-functions.zsh b/.config/zsh/zshrc.d/40-functions.zsh index 462ad21..218e328 100644 --- a/.config/zsh/zshrc.d/40-functions.zsh +++ b/.config/zsh/zshrc.d/40-functions.zsh @@ -340,7 +340,15 @@ mvln() { ## current repo instead of HOME. (Except when already there) cd() { if [[ $# -gt 0 ]]; then - builtin cd "$@" + # Call `ls` on paths that end on '/ls' and don't exist with the suffix. + # (When not properly pressing ) + if [[ ! -e ${@[-1]} && -e ${@[-1]%%/ls} ]]; then + builtin cd "${@[1,-2]}" "${@[-1]%%ls}" + pwd + ls + else + builtin cd "$@" + fi return fi