diff --git a/share/functions/__fish_anypython.fish b/share/functions/__fish_anypython.fish new file mode 100644 index 000000000..3a3819864 --- /dev/null +++ b/share/functions/__fish_anypython.fish @@ -0,0 +1,10 @@ +function __fish_anypython + # Try python3 first, because that's usually faster and generally nicer. + for py in python3 python2 python + command -sq $py + and echo $py + and return 0 + end + # We have no python. + return 1 +end diff --git a/share/functions/fish_config.fish b/share/functions/fish_config.fish index d4ef02c9a..aa05fa0f0 100644 --- a/share/functions/fish_config.fish +++ b/share/functions/fish_config.fish @@ -1,11 +1,7 @@ function fish_config --description "Launch fish's web based configuration" set -lx __fish_bin_dir $__fish_bin_dir - if command -sq python3 - python3 "$__fish_data_dir/tools/web_config/webconfig.py" $argv - else if command -sq python2 - python2 "$__fish_data_dir/tools/web_config/webconfig.py" $argv - else if command -sq python - python "$__fish_data_dir/tools/web_config/webconfig.py" $argv + if set -l python (__fish_anypython) + $python "$__fish_data_dir/tools/web_config/webconfig.py" $argv else echo (set_color $fish_color_error)Cannot launch the web configuration tool:(set_color normal) echo (set_color -o)fish_config(set_color normal) requires Python. diff --git a/share/functions/fish_update_completions.fish b/share/functions/fish_update_completions.fish index 96b55c59d..cf0151669 100644 --- a/share/functions/fish_update_completions.fish +++ b/share/functions/fish_update_completions.fish @@ -2,12 +2,8 @@ function fish_update_completions --description "Update man-page based completion # Don't write .pyc files, use the manpath, clean up old completions # display progress. set -l update_args -B $__fish_data_dir/tools/create_manpage_completions.py --manpath --cleanup-in ~/.config/fish/generated_completions --progress $argv - if command -qs python3 - python3 $update_args - else if command -qs python2 - python2 $update_args - else if command -qs python - python $update_args + if set -l python (__fish_anypython) + $python $update_args else printf "%s\n" (_ "python executable not found") return 1