zsh twisted tab completition is not working if python 3 is default system python Reproducible: Always Steps to Reproduce: 1. eselect python set <3.x python> 2. trial <TAB><TAB> 3. Actual Results: % trial Traceback (most recent call last): File "<string>", line 2, in <module> ImportError: No module named 'twisted' ERROR: Cannot find twisted completion function files in $dir:q
The original error is SyntaxError due to print function. The one I reported I'm getting after fixing it.
/usr/share/zsh/5.0.2/functions/Completion/Unix --- _twisted.old 2013-12-25 12:42:35.156987358 +0100 +++ _twisted 2013-12-25 12:42:47.570987870 +0100 @@ -28,13 +28,11 @@ function load_twisted_completions() { [[ -z $commands[twistd] ]] && echo 'ERROR: test command "twistd" not found in path' && return 1 - shebang=$(head -1 $commands[twistd]) - [[ $shebang != \#\!* ]] && echo 'ERROR: invalid shebang line for test script "twistd"' && return 1 - PYTHON=$shebang[3,-1] # strip #! off the shebang - PYTHON=${PYTHON# *} # remove any spaces between #! and command + PYTHON=python2 #debug PYTHON $PYTHON:q python_code=' +from __future__ import print_function import twisted, os.path dir = os.path.dirname(twisted.__file__) print (os.path.join(dir, "python", "zsh")) Is fixing it for me, however I tested only with completing a dir I have in my PWD elsewhere. I just skipped the detection of shebang binary because on gentoo it will always be generit `env python` for `which twisted` and we are in controll of what the expected executable name is.
This shouldn't be an issue anymore with recent versions of zsh since the completions are now generated dynamically using the current command line with the special --_shell-completion option.