pip
pip copied to clipboard
Broken fish completions on Windows
Description
Multiple issues preventing pip completions from working in Fish shell on Windows.
Fish ships with a file at /usr/share/fish/completions/pip.fish
containing
pip completion --fish 2>/dev/null | source
- Running
pip completion --fish
outputs
# pip fish completion start
function __fish_complete_pip
set -lx COMP_WORDS (commandline -o) ""
set -lx COMP_CWORD ( \
math (contains -i -- (commandline -t) $COMP_WORDS)-1 \
)
set -lx PIP_AUTO_COMPLETE 1
string split \ -- (eval $COMP_WORDS[1])
end
complete -fa "(__fish_complete_pip)" -c C:\Users\user\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe -m pip
# pip fish completion end
However the path to python is not valid in this context. It should be /c/Users/user/AppData/Local/Microsoft/WindowsApps/PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0/python.exe
which can be translated with the command cygpath -u 'C:\\Users\\user\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\python.exe'
- If I replace the contents of
completions/pip.fish
with the output from the command, but fix the path according to cygpath's output, I then get the errorpip complete: -m: unknown option
- If I quote the entire
python.exe -m pip
part (including path up to python.exe), I get no error but also no completions - If I replace that line with just
complete -fa "(__fish_complete_pip)" -c pip
, then completions appear to work correctly, except that: -
pip inst<tab>
turns intopip install\r
- I'm not certain how the \r ends up there specifically; it may be that this should be fixed in fish itself
Expected behavior
No response
pip version
pip 22.2.1 from C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\site-packages\pip (python 3.10)
Python version
Python 3.10.6
OS
Windows 10 19044.1889
How to Reproduce
- Install MSYS2
- Install fish shell
- Install Python from MS Store
- Open fish, type
pip <tab>
Output
No response
Code of Conduct
- [X] I agree to follow the PSF Code of Conduct.
Interoperation between MSYS and native Windows is known to be problematic, I would recommend using Python from Pacman instead. If you are interested to making this work, feel free to submit a pull request.