diff options
| author | Christoph Schlosser <cschlosser@google.com> | 2025-06-17 12:26:20 +0200 |
|---|---|---|
| committer | Christoph Schlosser <cschlosser@google.com> | 2025-06-17 10:32:18 +0000 |
| commit | e169dcb8b944d7679d245cb9a67a5fe0c56f9c37 (patch) | |
| tree | 74250bbcbc2a130289f63d8949837a236809a1db | |
| parent | 2447bd4bd20d497e22d13e6f117ad62750e4484d (diff) | |
| download | dots-e169dcb8b944d7679d245cb9a67a5fe0c56f9c37.tar.gz | |
Add upto script
| -rw-r--r-- | fish/functions/upto.fish | 13 |
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 |