Let's say I run inxi -C and want to output both inxi -C and the result of that command (CPU information) to pastebin. How do I do this in the most efficient way?

  • Copy paste isn't a valuable solution ? – Carpette Mar 31 '17 at 16:12
  • Sometimes that's not fast enough for me. – BananaLeafCat Mar 31 '17 at 17:15

Why, you can do that with the handy new forexample program (docs, unit tests) assuming the command to be run is something spawn can handle; otherwise, you'd need to write this tool directly in the shell itself.

$ CLIPBOARD=cat forexample echo hi
    $ echo hi

By default CLIPBOARD is pbcopy so either change the code or once forexample is properly setup in PATH (and expect installed) try something like

CLIPBOARD='xclip -in' forexample inxi -C
  • That looks like what I'm looking for. How do I install this? – BananaLeafCat Mar 31 '17 at 17:22
  • 1
    It's a TCL script so install the expect package and then chmod +x this script and stash it somewhere in $PATH. – thrig Mar 31 '17 at 17:54
  • Am I missing something here? tung@tung-Lenovo-Y50-70 ~ $ gather cat gather couldn't execute "pbcopy": no such file or directory while executing "open "| pbcopy" w" invoked from within "set clippyfh [open "| pbcopy" w]" (file "/usr/bin/gather" line 16) – BananaLeafCat Mar 31 '17 at 23:35
  • @BananaLeafCat that line has a comment right above it saying FIXME as copy-paste programs are unportable... – thrig Apr 1 '17 at 14:06
  • I think i have xclip but I don't know how to fix it accordingly... Could you give me an example? – BananaLeafCat Apr 1 '17 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.