1b7fc2f3aca32ba8713be0e27305c5cf578033f6

Author
Brad Urani <bradurani@gmail.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Add copybuffer function and keybinding (#5431)

* Add copybuffer function and keybinding:

binds ctrl-o to copy the command line buffer to the system clipboard.

* Add README

Diff

 1diff --git a/plugins/copybuffer/README.md b/plugins/copybuffer/README.md
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..da138bdbd5c27d3fd2829d4c76aae0c3dedc917c
 4--- /dev/null
 5+++ b/plugins/copybuffer/README.md
 6@@ -0,0 +1,11 @@
 7+# `copybuffer` plugin
 8+
 9+This plugin binds the ctrl-o keyboard shortcut to a command that copies the text
10+that is currently typed in the command line ($BUFFER) to the system clipboard.
11+
12+This is useful if you type a command - and before you hit enter to execute it - want
13+to copy it maybe so you can paste it into a script, gist or whatnot.
14+
15+```zsh
16+plugins=(... copybuffer)
17+```
18diff --git a/plugins/copybuffer/copybuffer.plugin.zsh b/plugins/copybuffer/copybuffer.plugin.zsh
19new file mode 100644
20index 0000000000000000000000000000000000000000..cc205d40f844c7be1df62132094b91d46ac05ba7
21--- /dev/null
22+++ b/plugins/copybuffer/copybuffer.plugin.zsh
23@@ -0,0 +1,14 @@
24+# copy the active line from the command line buffer 
25+# onto the system clipboard (requires clipcopy plugin)
26+
27+copybuffer () {
28+  if which clipcopy &>/dev/null; then
29+    echo $BUFFER | clipcopy
30+  else
31+    echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly."
32+  fi
33+}
34+
35+zle -N copybuffer
36+
37+bindkey "^O" copybuffer