Skip to content

Commit

Permalink
python: Split module completion to separate helper
Browse files Browse the repository at this point in the history
Avoids cwd in sys.path when using -c.
  • Loading branch information
scop committed Jun 1, 2017
1 parent 9e5522f commit abb3016
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions completions/python
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

_python_modules()
{
COMPREPLY+=( $( compgen -W "$( ${1:-python} -c 'import pkgutil
for mod in pkgutil.iter_modules(): print(mod[1])' 2>/dev/null )" -- "$cur" ) )
COMPREPLY+=( $( compgen -W \
"$( ${1:-python} ${BASH_SOURCE[0]%/*}/../helpers/python 2>/dev/null )" \
-- "$cur" ) )
}

_python()
Expand Down
2 changes: 1 addition & 1 deletion helpers/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
helpersdir = $(pkgdatadir)/helpers
helpers_DATA = perl
helpers_DATA = perl python

EXTRA_DIST = $(helpers_DATA)
6 changes: 6 additions & 0 deletions helpers/python
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- python -*-

import pkgutil

for mod in pkgutil.iter_modules():
print(mod[1])

0 comments on commit abb3016

Please sign in to comment.