Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
fc785de9
Commit
fc785de9
authored
Apr 08, 2013
by
Conrad Irwin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+safe-paste plugin
parent
b8b241f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
safe-paste.plugin.zsh
plugins/safe-paste/safe-paste.plugin.zsh
+54
-0
No files found.
plugins/safe-paste/safe-paste.plugin.zsh
0 → 100644
View file @
fc785de9
# Code from Mikael Magnusson: http://www.zsh.org/mla/users/2011/msg00367.html
#
# Requires xterm, urxvt, iTerm2 or any other terminal that supports bracketed
# paste mode as documented: http://www.xfree86.org/current/ctlseqs.html
# create a new keymap to use while pasting
bindkey
-N
paste
# make everything in this keymap call our custom widget
bindkey
-R
-M
paste
"^@"
-
"
\M
-^?"
paste-insert
# these are the codes sent around the pasted text in bracketed
# paste mode.
# do the first one with both -M viins and -M vicmd in vi mode
bindkey
'^[[200~'
_start_paste
bindkey
-M
paste
'^[[201~'
_end_paste
# insert newlines rather than carriage returns when pasting newlines
bindkey
-M
paste
-s
'^M'
'^J'
zle
-N
_start_paste
zle
-N
_end_paste
zle
-N
zle-line-init _zle_line_init
zle
-N
zle-line-finish _zle_line_finish
zle
-N
paste-insert _paste_insert
# switch the active keymap to paste mode
function
_start_paste
()
{
bindkey
-A
paste
main
}
# go back to our normal keymap, and insert all the pasted text in the
# command line. this has the nice effect of making the whole paste be
# a single undo/redo event.
function
_end_paste
()
{
#use bindkey -v here with vi mode probably. maybe you want to track
#if you were in ins or cmd mode and restore the right one.
bindkey
-e
LBUFFER+
=
$_paste_content
unset
_paste_content
}
function
_paste_insert
()
{
_paste_content+
=
$KEYS
}
function
_zle_line_init
()
{
# Tell terminal to send escape codes around pastes.
[[
$TERM
==
rxvt-unicode
||
$TERM
==
xterm
||
$TERM
=
xterm-256color
]]
&&
printf
'\e[?2004h'
}
function
_zle_line_finish
()
{
# Tell it to stop when we leave zle, so pasting in other programs
# doesn't get the ^[[200~ codes around the pasted text.
[[
$TERM
==
rxvt-unicode
||
$TERM
==
xterm
||
$TERM
=
xterm-256color
]]
&&
printf
'\e[?2004l'
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment