Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I set up an alias, function or variable as a shortcut to "2>&1 | tee build.log"?

11 views
Skip to first unread message

Carter Sanders

unread,
Jul 23, 2012, 5:29:00 PM7/23/12
to
As the subject line says, I'd like a quicker way to type "2>&1 | tee build.log"

Or even better, I'd like a shortcut which did expanded to 2>&1 | tee $1.$2.log" where $1 and $2 are taken from the current line.

I've tried a few different things and here are the problems I found

1. Aliases seem to apply to first words (or first word after another alias) only. So I'm pretty sure they can't help.
2. A function can work - e.g. "log ant compile", but it has the undesirable side effect of breaking bash completion as it moves the first arg to the second and then subcommands expansion won't work
3. A variable can sort of work e.g LOG='2>&1 | tee build.log', except it must be expanded manually with an esc-ctrl-E or the 2>&1 gets passed a parameter.

Does anybody know a better way to do this?

Thanks-
Carter
0 new messages