/usr/bin/activate-global-python-argcomplete is in python-argcomplete 0.6.9-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #! /usr/bin/python
# PYTHON_ARGCOMPLETE_OK
# Copyright 2012-2013, Andrey Kislyuk and argcomplete contributors.
# Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info.
'''
Activate the generic bash-completion script for the argcomplete module.
'''
import os, sys, argparse, argcomplete, shutil
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
dest_opt = parser.add_argument("--dest", help="Specify the bash completion modules directory to install into", default="/etc/bash_completion.d")
parser.add_argument("--user", help="Install into user directory (~/.bash_completion.d/)", action='store_true')
argcomplete.autocomplete(parser)
args = parser.parse_args()
if args.user:
args.dest = os.path.expanduser("~/.bash_completion.d/")
if not os.path.exists(args.dest):
try:
os.mkdir(args.dest)
except Exception as e:
parser.error("Path {d} does not exist and could not be created: {e}".format(d=args.dest, e=e))
elif not os.path.exists(args.dest) and args.dest != '-':
parser.error("Path {d} does not exist".format(d=args.dest))
activator = os.path.join(os.path.dirname(argcomplete.__file__), 'bash_completion.d', 'python-argcomplete.sh')
if args.dest == '-':
sys.stdout.write(open(activator).read())
else:
dest = os.path.join(args.dest, "python-argcomplete.sh")
sys.stdout.write("Installing bash completion script " + dest + "\n")
try:
shutil.copy(activator, dest)
except Exception as e:
err = str(e)
if args.dest == dest_opt.default:
err += "\nPlease try --user to install into a user directory, or --dest to specify the bash completion modules directory"
parser.error(err)
|