diff options
| -rwxr-xr-x | bin/kak-shell | 33 | ||||
| -rw-r--r-- | docs/faq.md | 2 | ||||
| -rw-r--r-- | docs/recipes.md | 10 |
3 files changed, 36 insertions, 9 deletions
diff --git a/bin/kak-shell b/bin/kak-shell index 2bf8bd5..d286626 100755 --- a/bin/kak-shell +++ b/bin/kak-shell @@ -1,10 +1,37 @@ #!/bin/sh +# Usage: +# +# kak-shell [session] [commands] +# +# Example – Basic: +# +# kak-shell +# +# Example – Connect to a session from the command-line and attach: +# +# kak-shell kanto :attach +# +# Example – Connect to a session interactively and attach: +# +# kak-shell '' :attach main() { - prompt_kakoune_session - [ "$text" ] || exit 1 + # Session + session=$1 + shift + + # Shell commands + commands=$@ + + # Prompt for a Kakoune session + if test -z "$session"; then + prompt_kakoune_session + [ "$text" ] || exit 1 + session=$text + fi - connect "$text" "$@" + # Connect to the given session and execute the shell commands + connect "$session" "$@" } connect() { diff --git a/docs/faq.md b/docs/faq.md index ffa0f54..dbd9bb6 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -90,7 +90,7 @@ Otherwise, it will interpret the entry as a session name and connect to it. If the session does not exists, the session will be started in daemon mode. Apart from running a connected shell, you can use `kak-shell` to run commands in the context of the session. -For example, you can run `kak-shell lazygit` to run [lazygit] connected to an arbitrary session. +For example, you can run `kak-shell kanto lazygit` to run [lazygit] connected to an arbitrary session. [lazygit]: https://github.com/jesseduffield/lazygit diff --git a/docs/recipes.md b/docs/recipes.md index af555d0..58ebeb5 100644 --- a/docs/recipes.md +++ b/docs/recipes.md @@ -2,14 +2,14 @@ ## Working with headless sessions with _kak-shell_ -`kak-shell :attach` lets you run a client connected to a session, just like the plain `kak -c <session-name>`. -But with `kak-shell :attach`, you have a list of all the active sessions and you can also create a new named session -which starts in headless mode, which is very useful for detaching and reattaching continually. +`kak-shell kanto :attach` lets you run a client connected to a session, just like the plain `kak -c <session-name>`. +But with `kak-shell kanto :attach`, you can create a new named session which starts in headless mode, +which is very useful for detaching and reattaching continually. -Therefore, `kak-shell :attach` replaces `kak -c <session-name>` and `kak -d -s <session-name>` +Therefore, `kak-shell kanto :attach` replaces `kak -c <session-name>` and `kak -d -s <session-name>` and can serve to spawn a client in whatever situation you are. -**Tip**: Alias `kak-shell` to `ks` and connect to a session with `ks a`. +**Tip**: Alias `kak-shell` to `ks` and connect to a session with `ks kanto a`. ## Custom prompt |
