aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKutsan Kaplan <me@kutsankaplan.com>2018-01-15 23:26:07 +0300
committerKutsan Kaplan <me@kutsankaplan.com>2018-01-15 23:26:07 +0300
commitb6e6f383e0b2f232eec80410ca4a9cc53d39b5a6 (patch)
treef76fc66cd10f3a19735897e4116dac437039d900
parenta48a80a1bfed72fff7aa80067ac6e49663543687 (diff)
downloadzsh-system-clipboard.zsh-b6e6f383e0b2f232eec80410ca4a9cc53d39b5a6.tar.xz
zsh-system-clipboard.zsh-b6e6f383e0b2f232eec80410ca4a9cc53d39b5a6.zip
Refactor foreach loops
-rw-r--r--zsh-system-clipboard.zsh24
1 files changed, 9 insertions, 15 deletions
diff --git a/zsh-system-clipboard.zsh b/zsh-system-clipboard.zsh
index ed2d8c9..24be9be 100644
--- a/zsh-system-clipboard.zsh
+++ b/zsh-system-clipboard.zsh
@@ -67,8 +67,7 @@ function _zsh_system_clipboard_api() {
}
function sub_get() {
- local CLIPBOARD_CONTENT=$(eval "${CLIPBOARD[get]}")
- echo -E "$CLIPBOARD_CONTENT"
+ echo -E $(${CLIPBOARD[get]})
}
local subcommand=${1:-''}
@@ -123,21 +122,16 @@ function zsh-system-clipboard-key-x() {
}
# Load functions as widgets
-foreach widget (
- zsh-system-clipboard-key-y
- zsh-system-clipboard-key-Y
- zsh-system-clipboard-key-p
- zsh-system-clipboard-key-P
- zsh-system-clipboard-key-x
-) {
- zle -N $widget
+foreach key (y Y p P x) {
+ zle -N zsh-system-clipboard-key-$key
}
# Normal mode bindings
-bindkey -M vicmd 'Y' zsh-system-clipboard-key-Y
-bindkey -M vicmd 'p' zsh-system-clipboard-key-p
-bindkey -M vicmd 'P' zsh-system-clipboard-key-P
+foreach key (Y p P) {
+ bindkey -M vicmd $key zsh-system-clipboard-key-$key
+}
# Visual mode bindings
-bindkey -M visual 'y' zsh-system-clipboard-key-y
-bindkey -M visual 'x' zsh-system-clipboard-key-x
+foreach key (y x) {
+ bindkey -M visual $key zsh-system-clipboard-key-$key
+}