From c55f4851662edcfd75c86bfb6c90416382749390 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 4 Jan 2021 12:17:20 +0530 Subject: [PATCH] Add an example of using the remote control protocol from a shell script --- docs/rc_protocol.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/rc_protocol.rst b/docs/rc_protocol.rst index afd868b7b..5940dd1c3 100644 --- a/docs/rc_protocol.rst +++ b/docs/rc_protocol.rst @@ -26,4 +26,16 @@ Set ``no_response`` to ``true`` if you don't want a response from kitty. The optional payload is a JSON object that is specific to the actual command being sent. The fields in the object for every command are documented below. +As a quick example showing how easy to use this protocol is, we will implement +the ``@ ls`` command from the shell using only shell tools. First, run kitty +as:: + + kitty -o allow_remote_control=socket-only --listen-on unix:/tmp/test + +Now, in a different terminal, you can get the pretty printed ``@ ls`` output +with the following command line:: + + echo -n '\x1bP@kitty-cmd{"cmd":"ls","version":[0,14,2]}\x1b\' | socat - unix:/tmp/test | tail -c +13 | jq -c '.data | fromjson' 2>/dev/null | jq . + + .. include:: generated/rc.rst