feat zsh: 搭配shift複製貼上到系統剪貼簿功能

This commit is contained in:
Yuan Chiu 2025-05-05 12:54:34 +08:00
parent 00859dd216
commit 2d3f1770b1

View File

@ -130,18 +130,26 @@ alias free='free -m' # Show sizes in MB
# Zsh Shift Select Mode # Zsh Shift Select Mode
zinit light jirutka/zsh-shift-select zinit light jirutka/zsh-shift-select
# 定義 Ctrl+Y複製選取的區塊 # Ctrl+Y 複製:複製到 zsh 與系統剪貼簿
function my_copy_region() { function my_copy_region() {
zle copy-region-as-kill zle copy-region-as-kill
print -rn -- "$CUTBUFFER" | clipcopy
} }
zle -N my_copy_region zle -N my_copy_region
bindkey '^Y' my_copy_region bindkey '^Y' my_copy_region
# 定義 Ctrl+P貼上yank # Ctrl+P 貼上zsh yank
function my_paste() { # function my_paste() {
zle yank # zle yank
# }
# zle -N my_paste
# bindkey '^P' my_paste
# 貼上clipboard-paste
function my_paste_from_clipboard() {
LBUFFER+=$(clippaste)
} }
zle -N my_paste zle -N my_paste_from_clipboard
bindkey '^P' my_paste # bindkey '^O' my_paste_from_clipboard # 例如 Ctrl+O
bindkey '^P' my_paste_from_clipboard # 例如 Ctrl+P
# overwrite ls # overwrite ls
if command -v colorls &> /dev/null; then if command -v colorls &> /dev/null; then