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

Re: Widget of the day: expand absolute path

On Fri, 28 Feb 2014 07:14:04 -0800
Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> It's probably obvious to most, but not at my level.  How does one 'use' 
> this?  Where does the code go? What activates it?

The zle manual page fully documents this, but we're between a rock and a
hard place there: either it's heavy going or it's not fully documented.

For a quick summary, see the section ZLE FUNCTIONS in the zshcontrib
manual page, which is where contributed widgets are described (as this
would be if I added it to the distribution).

Chapter 14 of From Bash to Zsh is recommended (certainly by Oliver and
me!)  See www.bash2zsh.com.

Here's a useful function I use for doing all this in one go that assumes
expand-absolute-path is autoloaded from your $fpath.

zlewidget() {
  # bindkey KEY to new WIDGET, possibly implemented by optional FUNCTION.
  # FUNCTION defaults to WIDGET and will be marked for autoload -Uz.

  local key=$1
  local widget=$2
  local function=${3:-$2}

  autoload -Uz $function
  zle -N $widget $function
  bindkey $key $widget
zlewidget '^xx' expand-absolute-path


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