The /filter command supports using an alias as its target output, using the -k switch. Example:
- /filter -wk @window /myalias *
This would dump everything from @window to /myalias, and each line would be interpreted as $1- within /myalias.
But what if you need to pass more than just the window output to your alias? Perhaps some instructions for the alias to handle the output in a special way? Well, you can't pass any parameters or switches to /myalias within the /filter command... Eg,
/filter -wk @window /myalias [color:red]something *[/color], will not work. Solution?
- /filter -wk @window $!myalias(something,$1-) *
Note the "!" in $!myalias() as this is important. Now when /myalias is called, $1 == something, and $2- == /filter output.
Here's a practical example, and the motive for discovery. I wanted to transfer output from one custom window to another, adding timestamps to the output. /filter doesn't support adding of timestamps, so I had to improvise.
- ALIAS filter_ts { echo -t [color:purple]$1 $$2- }
ALIAS copy_window { filter -wk @window1 $!filter_ts(@window2,$1-) * }[/color]
So when I call /copy_window, it will tell /filter to sent the contents of @window1 to /filter_ts, but with the $1 parameter of the target @window2.
You can also use built-in $identifiers instead of custom aliases, but you cannot use built-in /commands. Khaled disabled the ability for /commands to be used as $identifiers (after all the $quit(hahahah) abuse).
I hope you find this useful. Thanks to argv[0] for inspiration and support.