mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-29 05:03:46 +08:00
Add __fish_anypython helper function
This just finds the first usable python and echos it, so it can then be used. We have a few places where we use it and I'm about to add some more.
This commit is contained in:
parent
3ac1c29f79
commit
9b1fb6938e
10
share/functions/__fish_anypython.fish
Normal file
10
share/functions/__fish_anypython.fish
Normal file
|
@ -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
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user