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

Re: run-help as a widget



2009/12/18 JÃrg Sommer <joerg@xxxxxxxxxxxx>:
> Isn't it possible to get the position where <Esc>h was hit or the prefix
> and the suffix of the command? I would like to get help for true in this
> situation:
>
> % for h in $hosts; do ssh $h true<Esc>h; done

I had _split_shell_arguments_under already:

autoload -U split-shell-arguments

function _split_shell_arguments_under()
{
  local -a reply
  integer REPLY2
  split-shell-arguments
  #have to duplicate some of modify-current-argument to get the word
  #_under_ the cursor, not after.
  setopt localoptions noksharrays multibyte
  if (( REPLY > 1 )); then
    if (( REPLY & 1 )); then
      (( REPLY-- ))
    fi
  fi
  REPLY=${(Q)reply[$REPLY]}
}

function helpme()
{
  local REPLY
  _split_shell_arguments_under
  run-help $REPLY
}

zle -N helpme
bindkey '^Xh' helpme

-- 
Mikael Magnusson



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