zsh-users
 help / color / mirror / code / Atom feed
* pipe every command
@ 2012-11-05  8:23 shawn wilson
  2012-11-05 15:03 ` Benjamin R. Haskell
  0 siblings, 1 reply; 3+ messages in thread
From: shawn wilson @ 2012-11-05  8:23 UTC (permalink / raw)
  To: Zsh Users

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

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).


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: pipe every command
  2012-11-05  8:23 pipe every command shawn wilson
@ 2012-11-05 15:03 ` Benjamin R. Haskell
  2012-11-05 17:22   ` shawn wilson
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin R. Haskell @ 2012-11-05 15:03 UTC (permalink / raw)
  To: shawn wilson; +Cc: Zsh Users

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: pipe every command
  2012-11-05 15:03 ` Benjamin R. Haskell
@ 2012-11-05 17:22   ` shawn wilson
  0 siblings, 0 replies; 3+ messages in thread
From: shawn wilson @ 2012-11-05 17:22 UTC (permalink / raw)
  To: Benjamin R. Haskell; +Cc: Zsh Users

On Mon, Nov 5, 2012 at 3:03 PM, Benjamin R. Haskell <zsh@benizi.com> wrote:
> 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'
>

not as nicely baked in as i was hoping, but i guess it'll work. thanks


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-11-05 17:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-05  8:23 pipe every command shawn wilson
2012-11-05 15:03 ` Benjamin R. Haskell
2012-11-05 17:22   ` shawn wilson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).