From 6742d11a0e95db96e25a1132d240c03371f7e15d Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 26 Dec 2022 13:40:13 -0800 Subject: [PATCH] __fish_anypython: do not automatically run python3 on macOS macOS ships with a stub `/usr/bin/python3` which by default opens a dialog to install the command line tools. As we run `python3` initially at launch, this causes the dialog to appear on first run of fish, if the command line tools are not installed. Fix this by detecting the case of `/usr/bin/python3` on Darwin without the command line tools installed, and do not offer that as a viable python. --- share/functions/__fish_anypython.fish | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/share/functions/__fish_anypython.fish b/share/functions/__fish_anypython.fish index 67e094586..edbeecdd3 100644 --- a/share/functions/__fish_anypython.fish +++ b/share/functions/__fish_anypython.fish @@ -1,9 +1,18 @@ function __fish_anypython # Try python3 first, because that's usually faster and generally nicer. + # Do not consider the stub /usr/bin/python3 that comes installed on Darwin to be Python + # unless Xcode reports a real directory path. for py in python3 python3.{9,8,7,6,5,4,3} python2 python2.7 python - command -sq $py - and echo $py - and return 0 + if set -l py_path (command -s $py) + if string match -q /usr/bin/python3 -- $py_path + and string match -q Darwin -- "$(uname)" + and type -q xcode-select + and not xcode-select --print-path &>/dev/null + continue + end + echo $py + return 0 + end end # We have no python. return 1