summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Leferry 2 <alexherbo2@gmail.com>2017-11-12 09:54:21 +0100
committerAlex Leferry 2 <alexherbo2@gmail.com>2017-11-12 10:36:12 +0100
commit048ef06649a620f23070fae1eaff5d208ecb35e1 (patch)
tree2cc35e56e4307c810bc6bee11c418d3ec8b29391
Initial commit
-rw-r--r--CONTRIBUTING13
-rw-r--r--README.md54
-rw-r--r--UNLICENSE24
-rwxr-xr-xbin/kak-connect23
4 files changed, 114 insertions, 0 deletions
diff --git a/CONTRIBUTING b/CONTRIBUTING
new file mode 100644
index 0000000..8f69e18
--- /dev/null
+++ b/CONTRIBUTING
@@ -0,0 +1,13 @@
+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:
+
+ 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.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..d778dd3
--- /dev/null
+++ b/README.md
@@ -0,0 +1,54 @@
+[![IRC][shields/kakoune/badge]][freenode/kakoune]
+
+[Kakoune][] extension to connect to client / session.
+
+Dependencies
+------------
+
+- [shell.kak][]
+
+Installation
+------------
+
+1. Download the [script](bin/kak-connect)
+2. Place it on your `$PATH` (`~/bin` is a good choice if it is on your path)
+3. Set it to be executable (`chmod +x <file>…`)
+
+Running
+-------
+
+- When `$KAK_{SESSION,CLIENT}` are set: Open in the specified client
+- When `$KAK_SESSION` is set: Connect to the specified session
+- Else: Fall back to `kak`
+
+Usage
+-----
+
+Add a `:terminal` command:
+
+``` kak
+define-command terminal -params .. %{
+ shell \
+ -export session \
+ -export client \
+ %sh(echo $TERMINAL) -e %arg(@) \
+ %sh(test $# = 0 &&
+ echo $SHELL
+ )
+}
+```
+
+Launch a terminal then execute in it:
+
+``` sh
+kak-connect <file>
+```
+
+The file will be opened in the client from where `:terminal` was executed.
+
+You can configure your applications to use `kak-connect` instead of `kak`.
+
+[Kakoune]: http://kakoune.org
+[freenode/kakoune]: https://webchat.freenode.net?channels=kakoune
+[shields/kakoune/badge]: https://img.shields.io/badge/IRC-%23kakoune-blue.svg
+[shell.kak]: https://github.com/alexherbo2/shell.kak
diff --git a/UNLICENSE b/UNLICENSE
new file mode 100644
index 0000000..68a49da
--- /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 <http://unlicense.org/>
diff --git a/bin/kak-connect b/bin/kak-connect
new file mode 100755
index 0000000..92d0475
--- /dev/null
+++ b/bin/kak-connect
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+if [ $KAK_SESSION ] && [ $KAK_CLIENT ]; then
+ # Support to target line and column for the first file
+ # $ kak <file> +<line>:[column]
+ if test $# -ge 2; then
+ file=$(realpath $1)
+ target=$(echo $2 | pcregrep --om-separator ' ' --only-matching={1,2} '^[+]([0-9]+)(?::([0-9]+))?$')
+ if test -n "$target"; then
+ command="edit $file $target"
+ shift
+ shift
+ fi
+ fi
+ for file in $@; do
+ command="edit $(realpath $file); $command"
+ done
+ echo "eval -client $KAK_CLIENT '$command'" | kak -p $KAK_SESSION
+elif [ $KAK_SESSION ]; then
+ kak -c $KAK_SESSION "$@"
+else
+ kak "$@"
+fi