diff options
| -rw-r--r-- | CONTRIBUTING | 18 | ||||
| -rw-r--r-- | README.md | 33 | ||||
| -rw-r--r-- | UNLICENSE | 24 | ||||
| -rw-r--r-- | rc/prelude.kak | 7 | ||||
| -rw-r--r-- | rc/prelude.sh | 20 |
5 files changed, 102 insertions, 0 deletions
diff --git a/CONTRIBUTING b/CONTRIBUTING new file mode 100644 index 0000000..3d438b2 --- /dev/null +++ b/CONTRIBUTING @@ -0,0 +1,18 @@ +The preferred way to contribute would be through GitHub pull requests, +as an alternative patches can be discussed on the IRC channel. + +When contributing your first changes, please include an empty commit for +copyright waiver using the following message (replace 'John Doe' with +your name or nickname): + + John Doe Copyright Waiver + + I dedicate any and all copyright interest in this software to the + public domain. I make this dedication for the benefit of the public at + large and to the detriment of my heirs and successors. I intend this + dedication to be an overt act of relinquishment in perpetuity of all + present and future rights to this software under copyright law. + +The command to create an empty commit from the command-line is: + + git commit --allow-empty diff --git a/README.md b/README.md new file mode 100644 index 0000000..60e1749 --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# prelude.kak + +Prelude of shell blocks for [Kakoune]. + +## Installation + +Add [`prelude.kak`](rc/prelude.kak) to your autoload or source it manually. + +## Usage + +``` +kak_escape [text…] +``` + +Similar to `shell_escape` you may find in other programming languages, +`kak_escape` escapes each argument so that it can be safely passed to Kakoune. + +**Implementation**: +Single quotes each argument and doubles the single quotes inside. + +**Note**: +The resulted text should be used unquoted and is not intended for use in double quotes, nor in single quotes. + +**Example**: + +``` kak +evaluate-commands %sh{ + . "$kak_opt_prelude" + kak_escape evaluate-commands -try-client "$kak_client" 'echo Tchou' | kak -p "$kak_session" +} +``` + +[Kakoune]: https://kakoune.org diff --git a/UNLICENSE b/UNLICENSE new file mode 100644 index 0000000..efb9808 --- /dev/null +++ b/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to <https://unlicense.org/> diff --git a/rc/prelude.kak b/rc/prelude.kak new file mode 100644 index 0000000..88e4126 --- /dev/null +++ b/rc/prelude.kak @@ -0,0 +1,7 @@ +declare-option -hidden str prelude_path %sh(dirname "$kak_source") + +provide-module prelude %{ + declare-option -docstring 'Path to the prelude of shell blocks' str prelude "%opt{prelude_path}/prelude.sh" +} + +require-module prelude diff --git a/rc/prelude.sh b/rc/prelude.sh new file mode 100644 index 0000000..a3bdeac --- /dev/null +++ b/rc/prelude.sh @@ -0,0 +1,20 @@ +kak_escape() { + for text do + printf "'" + while true; do + case "$text" in + *"'"*) + head=${text%%"'"*} + tail=${text#*"'"} + printf "%s''" "$head" + text=$tail + ;; + *) + printf "%s' " "$text" + break + ;; + esac + done + done + printf '\n' +} |
