aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2020-11-25 15:26:10 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2020-11-25 15:26:10 +0100
commit7e5c39da0619a452dc307d960d442080f2bfbafb (patch)
tree2527630d1db20ac78f1fe7f8e99fc29298d37efa
parent86dc63d0348942bca7be03de7c1715a938821700 (diff)
downloaddotfiles-7e5c39da0619a452dc307d960d442080f2bfbafb.tar.gz
dotfiles-7e5c39da0619a452dc307d960d442080f2bfbafb.zip
[bash] add "upto" directory navigation function
-rw-r--r--bashrc10
1 files changed, 9 insertions, 1 deletions
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}"
+}