("--reflink" , "", f.comp_files), ("--remove-destination" , "", f.comp_files), ("--sparse=" , "", ["always", "auto", "never"]), ("--strip-trailing-slashes" , "", f.comp_files), (("-s", "--symbolic-link") , "", f.comp_files), (("-S", "--suffix") , "", []), (("-t", "--target-directory=") , "", f.comp_dirs), (("-T", "--no-target-directory=") , "", f.comp_dirs), (("-u", "--update") , "", f.comp_files), (("-v", "--verbose") , "", f.comp_files), (("-x", "--one-file-system") , "", f.comp_files), ("--reply=" , "", ["no", "query", "yes"]), ("--help" , "", f.comp_files), ("--version" , "", f.comp_files), ) def _backup_control(): return ["existing", "never", "nil", "none", "numbered", "off", "simple", "t"] def _attr_list(): return ["all", "links", "mode", "ownership", "timestamps"] class Cp(completion.ShellCompletionFunction): def __init__(self): self.arguments = [Argument(*item) for item in _cp_arguments(self)] def default(self): return self.comp_files() completion.register("cp", Cp)
"monitor", "msgminwait", "msgwait", "multiuser", "nethack", "next", "nonblock", "number", "obuflimit", "only", "other", "partial", "password", "paste", "pastefont", "pow_break", "pow_detach", "pow_detach_msg", "prev", "printcmd", "process", "quit", "readbuf", "readreg", "redisplay", "register", "remove", "removebuf", "reset", "resize", "screen", "scrollback", "select", "sessionname", "setenv", "setsid", "shell", "shelltitle", "silence", "silencewait", "sleep", "slowpaste", "sorendition", "source", "split", "startup_message", "stuff", "su", "suspend", "term", "termcap", "termcapinfo", "terminfo", "time", "title", "umask", "unsetenv", "utf8", "vbell", "vbell_msg", "vbellwait", "verbose", "version", "wall", "width", "windowlist", "windows", "wrap", "writebuf", "writelock", "xoff", "xon", "zmodem", "zombie", ) class Screen(completion.ShellCompletionFunction): def __init__(self): self.arguments = [Argument(*item) for item in _screen_arguments(self)] def default(self): return self.comp_programs() completion.register("screen", Screen) completion.register("byobu", Screen)
("-g" , "-- gui", f.modules_and_keywords), ("-k" , "-- keyword", f.modules_and_keywords), ("-p" , "-- port", []), ("-w" , "-- write out HTML", f.comp_files), ) class Pydoc(completion.ShellCompletionFunction): def __init__(self): self.arguments = [Argument(*item) for item in _pydoc_arguments(self)] def default(self): return self.modules_and_keywords() def modules_and_keywords(self): modules = [] for path in sys.path: try: entries = os.listdir(path) except OSError: continue for module in entries: name, ext = os.path.splitext(module) if ext in (".py", ".pyc", "pyo") or \ (os.path.isdir(os.path.join(path, module)) and not ext): modules.append(name) modules = list(set(modules)) modules.sort() return modules + keyword.kwlist completion.register("pydoc", Pydoc)
out = subprocess.Popen( ["dpkg", "-l"], stdout=subprocess.PIPE, stderr=subprocess.PIPE ).communicate()[0] except Exception: return [] try: out = out.decode() except UnicodeError: return [] candidates = [] vermax = max(len(line.split()[2]) for line in out.splitlines()[5:]) for line in out.splitlines()[5:]: info = line.split() version = info[2] description = " ".join(info[3:]) doc = "-- v{0:<{1}}{2}".format(version, vermax, description) candidates.append(Candidate(names=info[1], doc=doc)) return candidates class AptGet(completion.ShellCompletionFunction): def __init__(self): self.arguments = [Argument(*item) for item in _aptget_arguments(self)] class AptCache(completion.ShellCompletionFunction): def __init__(self): self.arguments = [Argument(*item) for item in _aptcache_arguments(self)] completion.register("apt-get", AptGet) completion.register("apt-cache", AptCache)
class Make(completion.ShellCompletionFunction): def __init__(self): self.arguments = [Argument(*item) for item in _make_arguments(self)] def default(self): makefile = None for fname in ["GNUmakefile", "makefile", "Makefile"]: if os.path.exists(fname): makefile = fname break if not makefile: return [] commands = [] try: fd = open(makefile, "r") except OSError: return [] current = self.parser.part[1] for line in fd: cols = line.split(":") if len(cols) == 2 and \ "$" not in cols[0] and \ "\t" not in cols[0] and \ not cols[0].startswith("#") and \ cols[0].startswith(current): commands.append(cols[0]) commands.sort() return commands completion.register("make", Make)
return progs return self.comp_files() def comp_other_prgs(self): for arg in reversed(self.parser.current_cmdline.split()): if arg != "sudo" and arg in completion.compfunctions: return completion.compfunctions[arg]().complete() def complete(self): candidates = self.comp_other_prgs() if candidates: return candidates if self.parser.part[1].startswith("-"): return self.options() current = self.parser.part[1] value = None for arg in self.arguments: if self.parser.current_option in arg.names: value = arg.callback break if value is None: value = self.default if hasattr(value, "__call__"): return value() else: return value completion.register("sudo", Sudo)
("-3" , "-- warn about Python 3.x incompatibilities", f.comp_files), ("-B" , "-- don't write .py[co] files on import", f.comp_files), ("-E" , "-- ignore PYTHON* environment variables (such as PYTHONPATH)", f.comp_files), ("-O" , "-- optimize generated bytecode slightly", f.comp_files), ("-OO" , "-- remove doc-strings in addition to the -O optimizations", f.comp_files), ("-Q" , "-- division options", f.comp_files), ("-S" , "-- don't imply 'import site' on initialization", f.comp_files), ("-W" , "-- warning control", f.comp_files), ("-c" , "-- program passed in as string (terminates option list)", f.comp_files), ("-d" , "-- debug output from parser", f.comp_files), ("-i" , "-- inspect interactively after running script", f.comp_files), ("-m" , "-- run library module as a script (terminates option list)", f.comp_files), ("-s" , "-- don't add user site directory to sys.path", f.comp_files), ("-t" , "-- issue warnings about inconsistent tab usage", f.comp_files), ("-tt" , "-- issue errors about inconsistent tab usage", f.comp_files), ("-u" , "-- unbuffered binary stdout and stderr", f.comp_files), ("-v" , "-- verbose (trace import statements)", f.comp_files), ("-x" , "-- skip first line of source, allowing use of non-Unix forms of #!cmd", f.comp_files), (("-V", "--version") , "-- print the Python version number and exit", f.comp_files), (("-h", "--help") , "-- print this help message and exit", f.comp_files), ) class Python(completion.ShellCompletionFunction): def __init__(self): self.arguments = [Argument(*item) for item in _python_arguments(self)] def default(self): return self.comp_files() completion.register("python", Python)
stdout=subprocess.PIPE, stderr=subprocess.PIPE ).communicate()[0] except Exception: return [] try: paths = paths.decode() except UnicodeError: return [] library = [] for path in paths.splitlines(): try: entries = os.listdir(path) except OSError: continue for lib in entries: if os.path.isdir(os.path.join(path, lib)): lib += os.sep library.append(lib) library.sort() return library class Ruby(completion.ShellCompletionFunction): def __init__(self): self.arguments = [Argument(*item) for item in _ruby_arguments(self)] def default(self): return self.comp_files() completion.register("ruby", Ruby)