Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: pipe every command



On Mon, 5 Nov 2012, shawn wilson wrote:

is there a way to put every command through a pipe or redirect?

i'd prefer some way that i can put logic in so that i can exclude some commands. but, basically i want everything to go through 'source-highlight' so:
ps ax | grep ssh
will end up:
ps ax | grep ssh | source-highlight -f esc256 -s shell

and:
sa
would end up:
sa | source-highlight -f esc256 -s shell

There might be a way to do this in the way you're talking about, but I accomplish a similar goal (being able to easily pipe things through `less`) using global aliases:

alias -g L='| less'

You could use:

# H = highlight
alias -g H='| source-highlight -f esc256 -s shell'

Then to use it, the following examples would expand into your example commands:

ps ax | grep ssh H

or:

sa H



sa doesn't look as nice as ps with this option, but hopefully i'll be able to determine what command was given and have some logic to give different options or none at all (for interactive commands like vim or tmux, this might not be so good - it fails hard with vim anyway).

Not very surprising -- Tmux and Vim require pretty full control of terminal I/O, so piping either one through a command won't do anything useful.

--
Best,
Ben



Messages sorted by: Reverse Date, Date, Thread, Author