summaryrefslogtreecommitdiffstats
path: root/fish/functions/upto.fish
diff options
context:
space:
mode:
Diffstat (limited to 'fish/functions/upto.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