fork/fish-shell

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

Johannes AltmanningerAdd OSC 133 prompt end markerb1e681030

master
1.1 KiB35 linesraw
1# localization: skip(private)
2function __fish_anypython
3    if set -l path (command -s python3)
4        # Do not consider the stub /usr/bin/python3 that comes installed on Darwin to be Python
5        # unless Xcode reports a real directory path.
6        and not begin
7            string match -q Darwin -- "$(uname)"
8            and string match -q /usr/bin/python3 -- $path
9            and type -q xcode-select
10            and not xcode-select --print-path &>/dev/null
11        end
12        echo $path
13        return 0
14    end
15    set -l best_path
16    set -l best_minor_version
17    set -l minor_version
18    for path in (path filter -fx -- $PATH/python3.*)
19        string match -rq -- '.*/python3\.(?<minor_version>\d+)$' $path
20        and test $minor_version -ge 5 # Python 3.5+
21        or continue
22        and begin
23            not set -q best_path[1]
24            or test $minor_version -gt $best_minor_version
25        end
26        set best_path $path
27        set best_minor_version $minor_version
28    end
29    if set -q best_path[1]
30        echo $best_path
31        return 0
32    end
33    # We have no python.
34    return 1
35end