tab-completion

bash autocompletion: add description for possible completions

左心房为你撑大大i 提交于 2019-12-02 22:57:10
Is it possible to make bash auto-completion look like in Cisco IOS shell? I mean to add short descriptions for each completion, like this: telnet 10.10.10. (TAB Pressed) 10.10.10.10 - routerA 10.10.10.11 - routerB where 10.10.10.10 and 10.10.10.11 are possible completions and routerA & routerB just descriptions (not to be executed). I know that bash can complete commands with "complete -W", but is it able to print descriptions for them? I have a solution to this that does not require pressing TAB more than twice or echoing any extra information. The key is to check whether there is only one

function name + tab does not return docstring in IPython

跟風遠走 提交于 2019-12-02 20:24:16
In IPython, I am used to write function( and then strike a tab, and get the contents of the docstring and a list of the named arguments. However, this stopped working since I installed IPython 2.0. Is there an explanation or a know fix? Oh, the shortcut is now shift+tab . Shift-tab only works when you place the edit cursor inside or after the object. Not when it's at the start of the object. This gotcha is not documented anywhere...! I filed jupyter issue Shift-Tab completion doesn't work when edit cursor is at the start of the object #1902 来源: https://stackoverflow.com/questions/22850566

Ambiguous tab completion not working in iPython on Windows

自作多情 提交于 2019-12-02 19:47:39
I am running IPython on Windows 7 x64 with pyreadline installed. If I start a new session and type: import numpy nu<TAB> Then nu autocompletes to numpy . However, if I start a new session and try this: import numpy n<TAB> Then nothing happens. I would expect it to cycle through all of the possible completions. I'm currently using out of the box config, do I need to change a setting to enable ambiguous tab completion or am I just out of luck? EDIT : To address the comment from ma3204, here is another example (start with fresh ipython session): [In 1]: value1 = 5 [In 2]: value2 = 6 [In 3]: va

Ajax autocomplete (or autosuggest) with TAB completion/autofill similar to shell command line completion?

拜拜、爱过 提交于 2019-12-02 18:36:43
I'm implementing a AJAX autocomplete/autosuggest feature, and not only do I want to do the usual show suggestions that are similar to what the user typed, but I'd like to let the user do partial completions to save typing. So, imagine my dictionary has these values in it: "green apple", "green pear", "green fruit", "blue sky", "blue water", "blue wake". If the user types in "g", the suggestions should be "green apple", "green pear", "green fruit", and I'd like to let the user hit TAB or something to update his query to "green ", then they could type "a" and they'd get completed to "green apple

how to send tab-key to python subprocess's stdin

一世执手 提交于 2019-12-01 10:11:16
Background: I have a Python subprocess that connects to a shell-like application, which uses the readline library to handle input, and that app has a TAB-complete routine for command input, just like bash. The child process is spawned, like so: def get_cli_subprocess_handle(): return subprocess.Popen( '/bin/myshell', shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, ) Everything works great, except tab-complete. Whenever my Python program passes the tab character, '\t' to the subprocess, I get 5 spaces in the STDIN, instead of triggering the readline library

how to send tab-key to python subprocess's stdin

六眼飞鱼酱① 提交于 2019-12-01 07:42:47
问题 Background: I have a Python subprocess that connects to a shell-like application, which uses the readline library to handle input, and that app has a TAB-complete routine for command input, just like bash. The child process is spawned, like so: def get_cli_subprocess_handle(): return subprocess.Popen( '/bin/myshell', shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, ) Everything works great, except tab-complete. Whenever my Python program passes the tab

python tab completion in windows

纵然是瞬间 提交于 2019-11-30 15:34:18
问题 I'm writing a cross-platform shell like program in python and I'd like to add custom tab-completion actions. On Unix systems I can use the built-in readline module and use code like the following to specify a list of possible completions when I hit the TAB key: import readline readline.parse_and_bind( 'tab: complete' ) readline.set_completer( ... ) How can I do this on Windows? I'd like to avoid relying on 3rd-party packages if possible. If no solution exists is it possible to simply trap TAB

python tab completion in windows

自作多情 提交于 2019-11-30 14:11:29
I'm writing a cross-platform shell like program in python and I'd like to add custom tab-completion actions. On Unix systems I can use the built-in readline module and use code like the following to specify a list of possible completions when I hit the TAB key: import readline readline.parse_and_bind( 'tab: complete' ) readline.set_completer( ... ) How can I do this on Windows? I'd like to avoid relying on 3rd-party packages if possible. If no solution exists is it possible to simply trap TAB key press so that I can implement my own from scratch? Do u have a look at PyReadline: a ctypes-based

Custom tab completion in python argparse

僤鯓⒐⒋嵵緔 提交于 2019-11-29 21:22:01
How to get shell tab completion cooperating with argparse in a Python script? #!/usr/bin/env python import argparse def main(**args): pass if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('positional', choices=['spam', 'eggs']) parser.add_argument('--optional', choices=['foo1', 'foo2', 'bar']) args = parser.parse_args() main(**vars(args)) With an executable flag set on the .py file, the expected results should be something like: $ ./example.py sp<tab> -> completes to "./example.py spam" $ ./example.py --op<tab> -> completes to "./example.py --optional" $ .

Tab-completion in Python interpreter in OS X Terminal

你离开我真会死。 提交于 2019-11-29 20:12:18
Several months ago, I wrote a blog post detailing how to achieve tab-completion in the standard Python interactive interpreter--a feature I once thought only available in IPython. I've found it tremendously handy given that I sometimes have to switch to the standard interpreter due to IPython unicode issues. Recently I've done some work in OS X. To my discontent, the script doesn't seem to work for OS X's Terminal application. I'm hoping some of you with experience in OS X might be able to help me trouble-shoot it so it can work in Terminal, as well. I am reproducing the code below import