I often run searches on my source code repo like this:
ack -l "foo bar" .
The searches can take 10-60 seconds and produce output like this:
path/to/file1 path/to/file2 path/to/file3
I frequently use this alias to open all of the files found in vim:
alias go='gvim `fc -s` -p'
This works OK, but
fc -s reruns the previous command, which can take seconds or minutes.
It would be very useful to append something like this to every command I run interactively:
| tee /tmp/lastCommand to all commands.
This way, if the output reveals itself to be useful, then I can do something else to it.
find . -type f
Which executes the following:
find . -type f | tee $lastOutLocation # Where lastOutputLocation=/tmp/lastOutput
You could then use something like this, to filter the previous command:
lastOut | grep "SomeString" # Where lastOut is an alias to cat $lastOutputLocation
Is there a mechanism I can use to do something like this? I don't think that aliases expose this kind of behaviour.
- Getting something that works with compound commands:
echo 'baz' ; echo 'bar'
- Figure out how to modify the command the user typed before running it
- Ignore things like interactive input. Don't want to capture password prompts
Possible solutions, I am currently exploring:
- Using TRAP and shopt as in this answer