4

How can I append | tee ~/.output to every single bash command?

I want to output the results of the last command so I can use them in a $variable.

Elijah Lynn
  • 12,272
  • 10
  • 61
  • 91
  • See [bash - automatically capture output of last executed command into a variable](http://stackoverflow.com/questions/5955577/bash-automatically-capture-output-of-last-executed-command-into-a-variable) – devnull Sep 23 '13 at 15:48
  • `I want to output the results of the last command so I can use them in a $variable.` -- The accepted answer in the above question does this exactly. – devnull Sep 23 '13 at 15:51

1 Answers1

2

I you want to append a string to every bash command you can do it by rebinding your enter key to add the command string. Or if you prefer create a secondary enter key and use it.

You should do something like this:

bind 'RETURN: "  | tee ~/.output \n"'

In this way, everytime you press enter the | tee ~/.output get appended.

This is a bash only solution.

Atropo
  • 12,231
  • 6
  • 49
  • 62