zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Oliver Kiddle <okiddle@yahoo.co.uk>
Cc: Zsh workers <zsh-workers@zsh.org>
Subject: Re: bracketed paste
Date: Mon, 7 Nov 2011 23:42:46 +0100	[thread overview]
Message-ID: <CAHYJk3Qg59oob5ZPQMR9-GH=RNBRvSsQEyjDdjZpk_p=5LiKJQ@mail.gmail.com> (raw)
In-Reply-To: <588.1320705064@thecus.kiddle.eu>

On 7 November 2011 23:31, Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
> Has anyone tried enabling the bracketed paste feature of xterm?

I have this for urxvt (now, this is a bit spread out in my config, so
I might miss some bits here, hope not).

bindkey -N paste
bindkey -R -M paste "^@"-"\M-^?" paste-insert
bindkey '^[[200~' _start_paste
bindkey -M paste '^[[201~' _end_paste
bindkey -M paste -s '^M' '^J'

function _zle_line_init() {
  # Tell urxvt to send escape codes around a paste
  [[ $TERM == rxvt-unicode || $TERM = xterm ]] && printf '\e[?2004h'
}

function _zle_line_finish() {
  # Tell it to stop
  [[ $TERM == rxvt-unicode || $TERM = xterm ]] && printf '\e[?2004l'
}

function _start_paste() {
  bindkey -A paste main
}

function _end_paste() {
  bindkey -e
  if [[ $_SPACE_AFTER_PASTE_QUOTE = 1 ]]; then
    LBUFFER+=${(q)_paste_content}' '
  else
    LBUFFER+=$_paste_content
  fi
  unset _paste_content
}

function _spaceafterpastequote() {
  if [[ $_SPACE_AFTER_PASTE_QUOTE = 1 ]]; then
    _SPACE_AFTER_PASTE_QUOTE=0
    zle -M "Not inserting a space after pastes, not quoting"
  else
    _SPACE_AFTER_PASTE_QUOTE=1
    zle -M "Inserting a space after pastes and quoting"
  fi
}

function _paste_insert() {
  _paste_content+=$KEYS
}

zle -N zle-line-init _zle_line_init
zle -N zle-line-finish _zle_line_finish
zle -N _start_paste
zle -N _end_paste
zle -N paste-insert _paste_insert
zle -N _spaceafterpastequote

-- 
Mikael Magnusson


  reply	other threads:[~2011-11-07 22:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-07 22:31 Oliver Kiddle
2011-11-07 22:42 ` Mikael Magnusson [this message]
2015-07-15 16:51 Yuri D'Elia
2015-07-15 17:33 ` Yuri D'Elia
2015-07-15 18:15   ` Mikael Magnusson
2015-07-15 18:43     ` Yuri D'Elia
2015-07-16  5:19 ` Oliver Kiddle
2015-07-16 14:32   ` Yuri D'Elia
2015-07-18  2:33     ` Oliver Kiddle
2015-07-18 11:55       ` Yuri D'Elia
2015-07-18 17:17       ` Bart Schaefer
2015-07-18 23:28         ` Oliver Kiddle
2015-07-16 20:15   ` Bart Schaefer
2015-07-18 12:05     ` Yuri D'Elia
2015-07-18 18:08       ` Bart Schaefer
2015-11-18 19:57 Yuri D'Elia
2015-11-19  6:05 ` Bart Schaefer
2015-11-19  9:33   ` Yuri D'Elia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHYJk3Qg59oob5ZPQMR9-GH=RNBRvSsQEyjDdjZpk_p=5LiKJQ@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=okiddle@yahoo.co.uk \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).