Get identifiers, names, paths, URLs and words from the previous command output and use them for the next command in xonsh.
| Save time. Forget about using mouse, touchpad or trackball to get any words from output to the next command. | Secure. The xontrib-output-search is not writing any output on the hard disk. Only latest not empty output stored in the memory. It works the same way as xonsh shell and the security level is the same. | Universal. Forget about searching autocomplete plugins for every app you use and get the identifiers from the output. |
If you like the idea click ⭐ on the repo and and tweet.
After release xonsh 0.10.0 (4283) you should set $XONSH_CAPTURE_ALWAYS=True in your ~/.xonshrc to use xontrib-output-search. Be aware that after this you can catch some issues around capturable tools (4283).
xpip install -U xontrib-output-search echo 'xontrib load output_search' >> ~/.xonshrc # Reload xonshAfter xontrib load output_search you have two ways to select tokens from latest not empty output:
- Press Alt + f hotkeys on Windows/Linux or Control + f on Mac
- Type
f__and press Tab key
If you use this key combination for another function and your muscle memory is strong just change the key combination before loading the xontrib:
# Alt+i combination. Meaning: @bindings.add('escape', 'i') $XONTRIB_OUTPUT_SEARCH_KEY='i' xontrib load output_search# Control+g combination. Meaning: @bindings.add('c-g') $XONTRIB_OUTPUT_SEARCH_KEY_BINDING='c-g' xontrib load output_search# Right+Left combination. Meaning: @bindings.add('right', 'left') $XONTRIB_OUTPUT_SEARCH_KEY_META='right' $XONTRIB_OUTPUT_SEARCH_KEY='left' # text placeholder will be `left__` xontrib load output_searchIn tmux there is the tmux fallback in case the output of last cmd is not available.
echo "Try https://github.com/xxh/xxh" # Try https://github.com/xxh/xxh git clone xx<Alt+F> git clone https://github.com/xxh/xxhecho '{"Try": "xontrib-output-search"}' # {"Try": "xontrib-output-search"} echo I should try se<Alt+F> echo I should try xontrib-output-searchenv | grep ^PATH= # PATH=/one/two:/three/four ls fo<Alt+F> ls /three/four Get the URL from previous output after typing git+:
echo "Try https://github.com/anki-code/xontrib-output-search" # Try https://github.com/anki-code/xontrib-output-search pip install git+xo<Alt+F> pip install git+https://github.com/anki-code/xontrib-output-searchGet the port number from previous output while typing the URL:
echo "The port number is 4242" # The port number is 4242 curl http://127.0.0.1:4<Alt+F> curl http://127.0.0.1:4242lolcat -h ... lolcat --s<Alt+F> lolcat --seed=SEEDThe xontrib-output-search is using tokenize-output for tokenizing.
Checking that output_search xontrib has been loaded:
xontrib list output_search # output_search installed loaded completer list | grep output_search # xontrib_output_searchNot working after xonsh 0.10.0 (4283)
Workaround: Check XONSH_CAPTURE_ALWAYS environment variable to bring the capturing of the output back i.e. $XONSH_CAPTURE_ALWAYS=True.
cat file is not captured (xonsh/issues/3744)
Workaround: cat file | head or cat file | grep text.
Workaround: f__ + Tab.
We're using the xonsh recommended prompt-toolkit shell type to test the output search xontrib. There could be the issues in the readline shell type. PRs are welcome!
Workaround: set $XONTRIB_OUTPUT_SEARCH_KEY='i' before xontrib load output_search.
- This package is the part of ergopack - the pack of ergonomic xontribs.
- This package was created with xontrib cookiecutter template.
- I was inspired by xontrib-histcpy. Thanks @con-f-use!