pip icon indicating copy to clipboard operation
pip copied to clipboard

Broken fish completions on Windows

Open TyPR124 opened this issue 2 years ago • 1 comments

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
  1. 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'

  1. 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 error pip complete: -m: unknown option
  2. If I quote the entire python.exe -m pip part (including path up to python.exe), I get no error but also no completions
  3. If I replace that line with just complete -fa "(__fish_complete_pip)" -c pip, then completions appear to work correctly, except that:
  4. pip inst<tab> turns into pip 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

  1. Install MSYS2
  2. Install fish shell
  3. Install Python from MS Store
  4. Open fish, type pip <tab>

Output

No response

Code of Conduct

TyPR124 avatar Aug 29 '22 17:08 TyPR124

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.

uranusjr avatar Aug 29 '22 17:08 uranusjr