From 7e5c39da0619a452dc307d960d442080f2bfbafb Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 25 Nov 2020 15:26:10 +0100 Subject: [bash] add "upto" directory navigation function --- bashrc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bashrc b/bashrc index b033207..722bbd5 100644 --- a/bashrc +++ b/bashrc @@ -21,5 +21,13 @@ pathadd ${DOTFILES_LOCATION}/bin source $DOTFILES_LOCATION/aliases -#exec xonsh +# navigate to first parent directory matching a regex +upto() { + if [ -z "$1" ]; then + return + fi + + local upto=$1 + cd "${PWD/\/$upto\/*//$upto}" +} -- cgit v1.2.3