Skip to main content

Get identifiers, names, paths, URLs and words from the previous command output and use them for the next command in xonsh.

Project description

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.

Note!

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).

Install

xpip install -U xontrib-output-search
echo 'xontrib load output_search' >> ~/.xonshrc
# Reload xonsh

Usage

After 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_search

In tmux there is the tmux fallback in case the output of last cmd is not available.

Use cases

Get URL from output

echo "Try https://github.com/xxh/xxh"
# Try https://github.com/xxh/xxh
git clone xx<Alt+F>
git clone https://github.com/xxh/xxh

Get key or value from JSON, Python dict and JavaScript object

echo '{"Try": "xontrib-output-search"}'
# {"Try": "xontrib-output-search"}
echo I should try se<Alt+F>
echo I should try xontrib-output-search

Get the path from environment

env | grep ^PATH=
# PATH=/one/two:/three/four
ls fo<Alt+F>
ls /three/four  

Complete the complex prefix

Get the URL from previous output after typing git+:

echo "Try https://github.com/tokenizer/xontrib-output-search"
# Try https://github.com/tokenizer/xontrib-output-search

pip install git+xo<Alt+F>
pip install git+https://github.com/tokenizer/xontrib-output-search

Get 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:4242

Get arguments from command help

lolcat -h
...
lolcat --s<Alt+F>
lolcat --seed=SEED

Development

The 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_search

Known issues

Not 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.

Alt+F combination may not working in PyCharm terminal

Workaround: f__ + Tab.

The readline shell type was not tested

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!

The Alt+F in the readline is to move forward

Workaround: set $XONTRIB_OUTPUT_SEARCH_KEY='i' before xontrib load output_search.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xontrib-output-search-0.6.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

xontrib_output_search-0.6.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file xontrib-output-search-0.6.0.tar.gz.

File metadata

  • Download URL: xontrib-output-search-0.6.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for xontrib-output-search-0.6.0.tar.gz
Algorithm Hash digest
SHA256 c0913b666e160286107c580e1eebb29657d9c8589f8a12ff59863fdada57f625
MD5 bbec829bf863cda38586876ab645c134
BLAKE2b-256 e9da9d6d4d819aee340c1dd190cd7e0c37c7628052132c93b4426a31993ae995

See more details on using hashes here.

File details

Details for the file xontrib_output_search-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for xontrib_output_search-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 634a974e60e2e68d93f1e18ac630fefc4af6d213a1873e8dabb8f63370b0cf00
MD5 ff8f198e48622d99c29c2524f7238cf3
BLAKE2b-256 3a45775d9de62b865af79025e630265575bac26b13c809b359fae4076335a069

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page