* default pipe @ 2005-07-25 14:57 GoTaR 2005-07-25 17:28 ` Bart Schaefer ` (2 more replies) 0 siblings, 3 replies; 11+ messages in thread From: GoTaR @ 2005-07-25 14:57 UTC (permalink / raw) To: zsh-users Hi! Is it possible somehow to set default pipe command? E.g. $ ls | <enter> to be executed as $ ls | less <enter> TIA -- GoTaR <priv0.onet.pl->gotar> http://vfmg.sourceforge.net/ http://tccs.sourceforge.net/ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default pipe 2005-07-25 14:57 default pipe GoTaR @ 2005-07-25 17:28 ` Bart Schaefer 2005-07-25 21:41 ` GoTaR 2005-07-25 17:29 ` zzapper 2005-07-25 19:09 ` DervishD 2 siblings, 1 reply; 11+ messages in thread From: Bart Schaefer @ 2005-07-25 17:28 UTC (permalink / raw) To: zsh-users On Jul 25, 4:57pm, GoTaR wrote: } } Is it possible somehow to set default pipe command? Well, it's possible *somehow* but ... } $ ls | <enter> This is syntactically incomplete, so zsh is going to print the PS2 prompt and wait for you to enter another command. In most cases I think this is what you'd want. The only way to subvert this is to hack the accept-line ZLE widget: function accept-pipe-as-terminator { setopt localoptions extendedglob if [[ "$BUFFER" = *\|[[:space:]]# ]] then # in 4.2.x and later, use BUFFER+=less BUFFER="$BUFFER less" fi zle .accept-line } zle -N accept-line accept-pipe-as-terminator ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default pipe 2005-07-25 17:28 ` Bart Schaefer @ 2005-07-25 21:41 ` GoTaR 0 siblings, 0 replies; 11+ messages in thread From: GoTaR @ 2005-07-25 21:41 UTC (permalink / raw) To: zsh-users On Mon, Jul 25, 2005 at 17:28:14 +0000, Bart Schaefer wrote: > } $ ls | <enter> > > This is syntactically incomplete, so zsh is going to print the PS2 > prompt and wait for you to enter another command. In most cases I > think this is what you'd want. Actually I always finish pipes in a line, so it's never what I want;] > The only way to subvert this is to hack the accept-line ZLE widget: [...] > zle -N accept-line accept-pipe-as-terminator Works perfect:) Thanks! -- GoTaR <priv0.onet.pl->gotar> http://vfmg.sourceforge.net/ http://tccs.sourceforge.net/ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default pipe 2005-07-25 14:57 default pipe GoTaR 2005-07-25 17:28 ` Bart Schaefer @ 2005-07-25 17:29 ` zzapper 2005-07-25 19:23 ` Wayne Davison 2005-07-25 19:09 ` DervishD 2 siblings, 1 reply; 11+ messages in thread From: zzapper @ 2005-07-25 17:29 UTC (permalink / raw) To: zsh-users On Mon, 25 Jul 2005 16:57:37 +0200, wrote: >Hi! > >Is it possible somehow to set default pipe command? E.g. > >$ ls | <enter> > >to be executed as > >$ ls | less <enter> > >TIA alias -g L=' | less' ls L (dunno if that's what you want!) -- zzapper vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?" http://www.rayninfo.co.uk/tips/ vim, zsh & success tips ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default pipe 2005-07-25 17:29 ` zzapper @ 2005-07-25 19:23 ` Wayne Davison 2005-07-25 19:35 ` zzapper 2005-07-27 17:35 ` Oliver Kiddle 0 siblings, 2 replies; 11+ messages in thread From: Wayne Davison @ 2005-07-25 19:23 UTC (permalink / raw) To: zzapper; +Cc: zsh-users On Mon, Jul 25, 2005 at 06:29:41PM +0100, zzapper wrote: > alias -g L=' | less' I too have some global aliases for simple pipe commands, but I have found it a little safer to use a short string of characters that is more unlikely to ever be a filename than a single capital letter. I have these that use a leading comma: alias -g ,e='|egrep' ,f='|fgrep' ,g='|grep' alias -g ,h='|head' ,t='|tail' ,w='|wc' alias -g ,l='|less' ,x='|xargs' I also have a second version of each of those aliases that combines stderr and stdout into the pipe, such as this one for less: alias -g ,,l='|&less' Yes, it does mean you need to type a space before the global alias, but I always typed a space before a "|" anyway, so that doesn't bother me. ..wayne.. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default pipe 2005-07-25 19:23 ` Wayne Davison @ 2005-07-25 19:35 ` zzapper 2005-07-26 13:16 ` Vincent Lefevre 2005-07-27 17:35 ` Oliver Kiddle 1 sibling, 1 reply; 11+ messages in thread From: zzapper @ 2005-07-25 19:35 UTC (permalink / raw) To: zsh-users On Mon, 25 Jul 2005 12:23:30 -0700, wrote: >On Mon, Jul 25, 2005 at 06:29:41PM +0100, zzapper wrote: >> alias -g L=' | less' > >I too have some global aliases for simple pipe commands, but I have >found it a little safer to use a short string of characters that is >more unlikely to ever be a filename than a single capital letter. >I have these that use a leading comma: > >alias -g ,e='|egrep' ,f='|fgrep' ,g='|grep' >alias -g ,h='|head' ,t='|tail' ,w='|wc' >alias -g ,l='|less' ,x='|xargs' > >I also have a second version of each of those aliases that combines >stderr and stdout into the pipe, such as this one for less: > >alias -g ,,l='|&less' > >Yes, it does mean you need to type a space before the global alias, but >I always typed a space before a "|" anyway, so that doesn't bother me. > Wayne, never thought to use a sequence ,x etc good idea. I have a convention to use uppercase for Global Aliases don't know if that's my idea or is general. -- zzapper vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?" http://www.rayninfo.co.uk/tips/ vim, zsh & success tips ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default pipe 2005-07-25 19:35 ` zzapper @ 2005-07-26 13:16 ` Vincent Lefevre 2005-07-26 13:34 ` DervishD 0 siblings, 1 reply; 11+ messages in thread From: Vincent Lefevre @ 2005-07-26 13:16 UTC (permalink / raw) To: zsh-users On 2005-07-25 20:35:20 +0100, zzapper wrote: > never thought to use a sequence ,x etc good idea. I have a > convention to use uppercase for Global Aliases don't know if that's > my idea or is general. Wouldn't a method based on bindkey (to insert some string) be safer? -- Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> 100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/> Work: CR INRIA - computer arithmetic / SPACES project at LORIA ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default pipe 2005-07-26 13:16 ` Vincent Lefevre @ 2005-07-26 13:34 ` DervishD 0 siblings, 0 replies; 11+ messages in thread From: DervishD @ 2005-07-26 13:34 UTC (permalink / raw) To: zsh-users Hi Vincent :) * Vincent Lefevre <vincent@vinc17.org> dixit: > On 2005-07-25 20:35:20 +0100, zzapper wrote: > > never thought to use a sequence ,x etc good idea. I have a > > convention to use uppercase for Global Aliases don't know if that's > > my idea or is general. > Wouldn't a method based on bindkey (to insert some string) be safer? I don't know if it is safer, but I prefer it. That's the way I have all my 'special' pipe commands implemented. Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 | http://www.dervishd.net http://www.pleyades.net & http://www.gotesdelluna.net It's my PC and I'll cry if I want to... ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default pipe 2005-07-25 19:23 ` Wayne Davison 2005-07-25 19:35 ` zzapper @ 2005-07-27 17:35 ` Oliver Kiddle 2005-07-27 18:42 ` Wayne Davison 1 sibling, 1 reply; 11+ messages in thread From: Oliver Kiddle @ 2005-07-27 17:35 UTC (permalink / raw) To: zsh-users Wayne Davison wrote: > I too have some global aliases for simple pipe commands, but I have > found it a little safer to use a short string of characters that is > more unlikely to ever be a filename than a single capital letter. > I have these that use a leading comma: > > alias -g ,e='|egrep' ,f='|fgrep' ,g='|grep' I tend to prefer bindkey -s instead of global aliases for such sequences. It has the advantage that it is expanded so you can see what it is going to do. Oliver This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default pipe 2005-07-27 17:35 ` Oliver Kiddle @ 2005-07-27 18:42 ` Wayne Davison 0 siblings, 0 replies; 11+ messages in thread From: Wayne Davison @ 2005-07-27 18:42 UTC (permalink / raw) To: Oliver Kiddle; +Cc: zsh-users On Wed, Jul 27, 2005 at 07:35:06PM +0200, Oliver Kiddle wrote: > I tend to prefer bindkey -s instead of global aliases for such > sequences. It has the advantage that it is expanded so you can see > what it is going to do. I much prefer the global aliases because they take up less room on the line, are easier to edit (since they remain short), and I like them unexpanded in the history. To each his own. ..wayne.. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default pipe 2005-07-25 14:57 default pipe GoTaR 2005-07-25 17:28 ` Bart Schaefer 2005-07-25 17:29 ` zzapper @ 2005-07-25 19:09 ` DervishD 2 siblings, 0 replies; 11+ messages in thread From: DervishD @ 2005-07-25 19:09 UTC (permalink / raw) To: GoTaR; +Cc: zsh-users Hi GoTaR :) * GoTaR <gotar@poczta.onet.pl> dixit: > Is it possible somehow to set default pipe command? E.g. > > $ ls | <enter> > > to be executed as > > $ ls | less <enter> Not exactly what you want, but I have my useless Windoze keys mapped to that. When I hit my 'menu' key, "| less <enter>" is automatically entered in the command line. Is very easy if you use Linux: just add a string to the key you want to do the dirty job and after that 'bindkey' that string to the command you want to be automatically entered. That's all. If you use Linux and a Windoze keyboard, I can post you the things you need to add to your keymap and zshenv/zshrc files. Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 | http://www.dervishd.net http://www.pleyades.net & http://www.gotesdelluna.net It's my PC and I'll cry if I want to... ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2005-07-27 18:42 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2005-07-25 14:57 default pipe GoTaR 2005-07-25 17:28 ` Bart Schaefer 2005-07-25 21:41 ` GoTaR 2005-07-25 17:29 ` zzapper 2005-07-25 19:23 ` Wayne Davison 2005-07-25 19:35 ` zzapper 2005-07-26 13:16 ` Vincent Lefevre 2005-07-26 13:34 ` DervishD 2005-07-27 17:35 ` Oliver Kiddle 2005-07-27 18:42 ` Wayne Davison 2005-07-25 19:09 ` DervishD
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).