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

Re: prepopulate BUFFER



> On 29 April 2022 at 15:18 Pier Paolo Grassi <pierpaolog@xxxxxxxxx> wrote:
> actually I have another question, is there a similar way of setting the
> initial cursor position like I would do setting the CURSOR var in zle
> widgets?

As long as something else hasn't already taken over zle-line-init, you
can do something like

zle-line-init() {                
  if (( set_cursor )); then
    (( CURSOR = set_cursor ))
    set_cursor=0
  fi
}
zle -N zle-line-init

then you can use it like

print -z "foo bar"; typeset -gi set_cursor=4

pws




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