summaryrefslogtreecommitdiffstats
path: root/fish
diff options
context:
space:
mode:
authorChristoph Schlosser <cschlosser@google.com>2025-06-17 12:26:20 +0200
committerChristoph Schlosser <cschlosser@google.com>2025-06-17 10:32:18 +0000
commite169dcb8b944d7679d245cb9a67a5fe0c56f9c37 (patch)
tree74250bbcbc2a130289f63d8949837a236809a1db /fish
parent2447bd4bd20d497e22d13e6f117ad62750e4484d (diff)
downloaddots-e169dcb8b944d7679d245cb9a67a5fe0c56f9c37.tar.gz
Add upto script
Diffstat (limited to 'fish')
-rw-r--r--fish/functions/upto.fish13
1 files changed, 13 insertions, 0 deletions
diff --git a/fish/functions/upto.fish b/fish/functions/upto.fish
new file mode 100644
index 0000000..7a9f40d
--- /dev/null
+++ b/fish/functions/upto.fish
@@ -0,0 +1,13 @@
+function upto -a where -d "Go up to a certain directory"
+ set -l pieces ( pwd | tr "/" "\n")
+
+ if contains -- $where $pieces
+ set -l p (contains --index -- $where $pieces)
+ set -l dest (printf "%s\n" $pieces[1..$p] | tr "\n" "/")
+ cd "$dest"
+
+ return
+ end
+
+ return 1
+end