bash: any way to reuse the last output?
Ben Stringer
ben at burbong.com
Sat Jan 24 01:14:36 UTC 2004
On Sat, 2004-01-24 at 11:39, Herculano de Lima Einloft Neto wrote:
> Here's an interesting hack. It won't do after all, since it breaks
> things like colors and columns in ls output, man page scrolling.. and
> appends an ugly thing to all the lines in your history, with time. :)
> But it's worth noting, since it illustrates useful resources:
> (could it be fixed?)
>
> .inputrc:
> "^[k": accept-line
> "^M": " | tee /tmp/h_lastcmd.out ^[k"
>
> .bash_profile:
> export __=/tmp/h_lastcmd.out
>
> If you try it, Alt-k will stand for the old Enter; use "command $__" to
> access the last output.
Doesn't work for me - for some reason bash is not picking up those
changes in my $HOME/.inputrc.
But this looks like a great way to achieve what you are after. One
problem with the script I posted is it won't handle line-continuation.
Eg.
find . |\
wc
But your method should handles this, as long as you use Alt-k for all
but the final line.
Looks like READLINE gives you a lot of powerful features here.
Cheers, Ben
--
.O. Ben Stringer
..O ben at burbong.com
OOO linux|java|majitek|gnu
More information about the fedora-list
mailing list