Sample Header Ad - 728x90

zsh - optimize copy, cut, paste using ctrl+c, ctrl+x, ctrl+v

3 votes
1 answer
1795 views
I am using the following config in my .zshrc. if [[ -t 0 && $- = *i* ]] then # change Ctrl+C to Ctrl+I stty start '' stty stop '' stty quit '' stty erase '' stty kill '' stty eof '' # Ctrl + D stty rprnt '' stty werase '' stty lnext '' stty discard '' fi # change Ctrl+C to Ctrl+Q stty intr '^q' # change Ctrl+z to Ctrl+j stty susp '^j' # change Ctrl+V to Ctrl+K bindkey '^k' quoted-insert # for zle _copy-using-xsel() { if ((REGION_ACTIVE)) then zle copy-region-as-kill printf "$CUTBUFFER" | xsel -i --clipboard ((REGION_ACTIVE = 0)) fi } zle -N _copy-using-xsel bindkey '^C' _copy-using-xsel # Copy text _cut-using-xsel() { if ((REGION_ACTIVE)) then zle copy-region-as-kill printf "$CUTBUFFER" | xsel -i --clipboard zle kill-region fi } zle -N _cut-using-xsel bindkey '^X' _cut-using-xsel # Cut text _paste-copy-using-xsel() { LBUFFER+="$(xsel -b -o)" } zle -N _paste-copy-using-xsel bindkey '^V' _paste-copy-using-xsel # Paste It enables me to copy using ctrl+c, cut using ctrl+x, paste using ctrl+v. However, I noticed that the operations are slow. I mean it appears to me that, it takes half a second to cut. Is it due to the use of xsel? How can I optimize my keybindings so that the lag is gone.
Asked by Ahmad Ismail (2998 rep)
Aug 16, 2020, 08:21 AM
Last activity: Aug 16, 2020, 04:51 PM