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 of xontrib-output-search click ⭐ on the repo and stay tuned by watching releases.

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
  • Type f__ and press Tab key

Features

Words tokenizing

$ echo "Hello world"
Hello world
$ echo The second word is wo<Alt+F>
$ echo The second word is world

URL example:

$ 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

JSON, Python dict and JavaScript object tokenizing

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

env tokenizing

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

Complex prefixes autocomplete

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

Development

Tokenizers

Tokenizer is a functions which extract tokens from the text.

Priority Tokenizer Text Tokens
1 dict {"key": "val as str"} ['key', 'val as str']
2 env PATH=/bin:/etc ['PATH', '/bin:/etc', '/bin', '/etc']
3 split Split me \n now! ['Split', 'me', 'now!']
4 strip {Hello} ['Hello']

You can create your tokenizer and add it to tokenizers_all in tokenize_output.py.

Tokenizing is a recursive process where every tokenizer returns final and new tokens. The final tokens directly go to the result list of tokens. The new tokens go to all tokenizers again to find new tokens. As result if there is a mix of json and env data in the output it will be found and tokenized in appropriate way.

Test and debug

Run tests:

cd ~
git clone https://github.com/anki-code/xontrib-output-search
cd xontrib-output-search
pytest

To debug the tokenizer:

echo "Hello world" | python tokenize_outupt.py --pipe

Check that output_search loaded:

$ xontrib list output_search
output_search  installed  loaded

$ completer list | grep output_search
xontrib_output_search

Known issues

cat file is not captured

Workaround: cat file | head.

Alt+F combination may not working in PyCharm terminal

Workaround: f__ + Tab.

Thanks

I was inspired by xontrib-histcpy. Thanks @con-f-use!

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.4.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

xontrib_output_search-0.4.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xontrib-output-search-0.4.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200325 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for xontrib-output-search-0.4.0.tar.gz
Algorithm Hash digest
SHA256 67cf8eb06f4cb666f9124515099d49d8ec3f381580a310dc5f70a9f3fa3637ca
MD5 a6db7eac96beffb39b7c41c1c357c66c
BLAKE2b-256 663d573afbc88f7ece25d9a4e81c718b76cdf89f769e9b293f9f1fa03659a241

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xontrib_output_search-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200325 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for xontrib_output_search-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 882489364165139392f882e5541a3007316fd7729add17e6df66a301f3f42595
MD5 ac87ced201be5513138d430f63f68c1d
BLAKE2b-256 3021d024e9ea1e9f801cfcd8e36a82fbaf4a2f7127e9ac3beb54031573bc7b56

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