Package: xontrib-output-search
Get identifiers, names, paths, URLs and words from the previous command output and use them for the next command inxonsh.Features💡Universal. Forget about searching autocomplete plugins for every app you use. Just get the identifiers from the previous output.⏳Save time. Forget about using mouse, touchpad or trackball to get any words from screen to the next command.🔒Secure. It works the same way as xonsh shell and the security level is the same.Installxpipinstall-Uxontrib-output-searchBefore usageThere are three ways to use output search:Recommended. Usetmuxto run xonsh and use output search. See instructions below.Not recommended. Set$XONSH_CAPTURE_ALWAYS=Trueand be ready some tools will freeze because of capturing e.g.git config --help. Details: afterxonsh release 0.10.0(4283) you should set$XONSH_CAPTURE_ALWAYS=Truein your~/.xonshrcto make output capturable. This approach has issues and we decided that the best solution for output search is to use the terminal window managers and we supporttmux. In this case the output will be captured from the screen.Alternative. You canadd supportany terminal emulator or terminal window manager like tmux that can capture the content of the terminal. PR is welcome!UsageThe recommended way as described above:zsh
alias tx="tmux new-session xonsh ';' set -g status off"  # add alias to run xonsh in tmux without bottom status bar
tx  # run xonsh in tmux
xontrib load output_search  # add this to ~/.xonshrcAfter loading you can select tokens from latest not empty output:Windows/Linux: PressAlt+fhotkeys after getting the output of the previous command.Mac: PressControl+fhotkeys after getting the output of the previous command.Any OS: Typef__orf__<beginning of the word you want>and pressTab.If you use this key combination for another function and your muscle memory is strong just change
thekey combinationbefore
loading the xontrib:# Alt+i combination. Meaning for prompt-toolkit: @bindings.add('escape', 'i')$XONTRIB_OUTPUT_SEARCH_KEY='i'xontribloadoutput_search# This approach is recommended for Mac users because `c-<key>` is represented# the Control key that has less intersections with other Mac hotkeys.## Control+g combination. Meaning for prompt-toolkit: @bindings.add('c-g')$XONTRIB_OUTPUT_SEARCH_KEY_BINDING='c-g'xontribloadoutput_search# Right+Left combination. Meaning for prompt-toolkit: @bindings.add('right', 'left')$XONTRIB_OUTPUT_SEARCH_KEY_META='right'$XONTRIB_OUTPUT_SEARCH_KEY='left'# the text placeholder will be `left__`xontribloadoutput_searchIntmuxthere isthe tmux fallbackin case the output of last cmd is not available.Use casesGet URL from outputecho"Try https://github.com/xxh/xxh"# Try https://github.com/xxh/xxhgitclonexx<Alt+F>
gitclonehttps://github.com/xxh/xxhGet key or value from JSON, Python dict and JavaScript objectecho'{"Try": "xontrib-output-search"}'# {"Try": "xontrib-output-search"}echoIshouldtryse<Alt+F>echoIshouldtryxontrib-output-searchGet the path from environmentenv|grep^PATH=# PATH=/one/two:/three/fourlsfo<Alt+F>
ls/three/fourComplete the complex prefixGet the URL from previous output after typinggit+:echo"Try https://github.com/anki-code/xontrib-output-search"# Try https://github.com/anki-code/xontrib-output-searchpipinstallgit+xo<Alt+F>
pipinstallgit+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 4242curlhttp://127.0.0.1:4<Alt+F>
curlhttp://127.0.0.1:4242Get arguments from command helplolcat-h# ...lolcat--s<Alt+F>
lolcat--seed=SEEDUsetokenize-outputas a tool$(echo 'Hello "world"!' | tokenize-output -p).split()
# ['Hello', 'world']Environement variables$XONTRIB_OUTPUT_SEARCH_WARNING- show warnings from xontrib. DefaultTrue.DevelopmentThe xontrib-output-search is usingtokenize-outputfor tokenizing.Checking thatoutput_searchxontrib has been loaded:xontriblistoutput_search# output_search  installed  loadedcompleterlist|grepoutput_search# xontrib_output_searchKnown issuesAlt+Fmay not working in PyCharm terminalWorkaround:f__+Tab.Alt+Fin the readline is to move forwardWorkaround: set$XONTRIB_OUTPUT_SEARCH_KEY='i'beforexontrib load output_search.Not working afterxonsh 0.10.0(4283)Workaround: CheckXONSH_CAPTURE_ALWAYSenvironment variable to bring the capturing of the output back i.e.$XONSH_CAPTURE_ALWAYS=True.cat fileis not captured (xonsh/issues/3744)Workaround:cat file | headorcat file | grep text.The readline shell type was not testedWe'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!LinksThis package is the part ofergopack- the pack of ergonomic xontribs.This package was created withxontrib cookiecutter template.I was inspired byxontrib-histcpy. Thanks @con-f-use!