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

Re: Display a function



> but I don't know how to use
> 
> functionname and then "expand-last-word"

expand-last-word() {
  setopt localoptions extendedglob

  local skip="${(M)LBUFFER%%[   \;\|\{\}]##}"
  local word="${(M)${LBUFFER%${skip}}%%[^   \;\|\{\}]##}" exp

  if (( $+aliases[$word] )); then
    exp="$aliases[$word]"
  elif (( $+functions[$word] )); then
    exp="$functions[$word]"
  elif (( $+commands[$word] )); then
    exp="$commands[$word]"
  fi

  [[ -n "$exp" ]] && LBUFFER="${LBUFFER%${word}${skip}}${exp}${skip}"
}

zle -N expand-last-word

bindkey "ESCn"        expand-last-word

And then just press ALT-n after typing the functionname.
 Andy.

-- 
           http://peru.spiegl.de  Our project
      http://radiomaranon.org.pe  Radio Marañón, Jaén, Perú
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Give a man a fish, and he will eat for a day.
 Teach a man to fish and he will eat for a lifetime.



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