4 Aug 07:09
zle widgets coolness: pipe command template
From: Max Mikhanosha <max <at> openchat.com>
Subject: zle widgets coolness: pipe command template
Newsgroups: gmane.comp.shells.zsh.devel
Date: 2008-08-04 05:09:34 GMT
Expires: This article expires on 2008-08-18
Subject: zle widgets coolness: pipe command template
Newsgroups: gmane.comp.shells.zsh.devel
Date: 2008-08-04 05:09:34 GMT
Expires: This article expires on 2008-08-18
Wrote my first zle widget, thought I'll share: # define-pipe-widget <widget-name> "template1" "template2" .... # # Defines "pipe widget" templates. Its hard to describe the best way # is through an example: # # define-pipe-widget insert_grep "grep \"@@@\"" "grep -i \"@@@\"" "grep @@@" # define-pipe-widget insert_head "head" "head\n" # # bindkey "\M-g" insert_grep # bindkey "\M-h" insert_head # # Now pressing Alt-G will insert (| represents cursor position) # # On empty command line: grep "|" # # On non-empty command line: <old cmdline> | grep "|" # # Pressing Alt-G one more time cycles through choices # ie: # ... | grep "|" # ... | grep -i "|" # ... | grep # # If template has \n in the end, then it will be auto-accepted: # # Alt-H does: ... | head <cursor here> # 2nd Alt-H does ... | head<Enter> #(Continue reading)
RSS Feed