summaryrefslogtreecommitdiffstats
path: root/fish/functions/upto.fish
blob: 7a9f40d91d89052a9dc893a4ddaaa73d09f22980 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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