fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes AltmanningerMark private functions that don't need localizationa53db7256

master
598 B26 linesraw
1# localization: skip(private)
2# Generates a list of parent directories for a given path
3# i.e. /a/b/c/d -> [/a/b/c/, /a/b/, /a/, and /a]
4function __fish_parent_directories
5    if test (count $argv) -ne 1
6        # for use in completions, so don't spew error messages
7        return 1
8    end
9
10    set -l splits (string split '/' $argv[1])
11    set -l parents
12
13    for split in $splits
14        if test (string length "$split") -eq 0
15            continue
16        end
17
18        set parents "$parents[1]/$split" $parents
19    end
20
21    for parent in $parents
22        echo $parent
23    end
24
25    return 0
26end