When using the --listen-on option have kitty @ automatically connect to the socket even when --to is not specified
The listen on value is set in the env of the child processes, so kitty @ can read it when run from inside kitty.
This commit is contained in:
parent
d964146f8c
commit
634d262b64
13
kitty/cli.py
13
kitty/cli.py
@ -109,11 +109,14 @@ regardless of this option.
|
||||
--listen-on
|
||||
Tell kitty to listen on the specified address for control
|
||||
messages. For example, :option:`{appname} --listen-on`=unix:/tmp/mykitty or
|
||||
:option:`{appname} --listen-on`=tcp:localhost:12345. On Linux systems, you can also use abstract
|
||||
UNIX sockets, not associated with a file, like this: :option:`{appname} --listen-on`=unix:@mykitty.
|
||||
To control kitty, you can send it commands with :italic:`kitty @` using the :option:`kitty @ --to` option
|
||||
to specify this address. Note that this option will be ignored, unless you set
|
||||
:opt:`allow_remote_control` to yes in :file:`kitty.conf`.
|
||||
:option:`{appname} --listen-on`=tcp:localhost:12345. On Linux systems, you can
|
||||
also use abstract UNIX sockets, not associated with a file, like this:
|
||||
:option:`{appname} --listen-on`=unix:@mykitty. To control kitty, you can send
|
||||
it commands with :italic:`kitty @` using the :option:`kitty @ --to` option to
|
||||
specify this address. This option will be ignored, unless you set
|
||||
:opt:`allow_remote_control` to yes in :file:`kitty.conf`. Note that if you run
|
||||
:italic:`kitty @` within a kitty window, there is no need to specify the :italic:`--to`
|
||||
option as it is read automatically from the environment.
|
||||
|
||||
|
||||
# Debugging options
|
||||
|
||||
@ -203,10 +203,12 @@ def macos_cmdline():
|
||||
return ans
|
||||
|
||||
|
||||
def setup_environment(opts):
|
||||
def setup_environment(opts, args):
|
||||
extra_env = opts.env.copy()
|
||||
if opts.editor != '.':
|
||||
os.environ['EDITOR'] = opts.editor
|
||||
if args.listen_on:
|
||||
os.environ['KITTY_LISTEN_ON'] = args.listen_on
|
||||
set_default_env(extra_env)
|
||||
|
||||
|
||||
@ -264,7 +266,7 @@ def _main():
|
||||
return
|
||||
init_glfw(args.debug_keyboard) # needed for parsing native keysyms
|
||||
opts = create_opts(args)
|
||||
setup_environment(opts)
|
||||
setup_environment(opts, args)
|
||||
try:
|
||||
with setup_profiling(args):
|
||||
# Avoid needing to launch threads to reap zombies
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import types
|
||||
@ -164,6 +165,8 @@ def main(args):
|
||||
else:
|
||||
no_response = func.no_response
|
||||
send['no_response'] = no_response
|
||||
if not global_opts.to and 'KITTY_LISTEN_ON' in os.environ:
|
||||
global_opts.to = os.environ['KITTY_LISTEN_ON']
|
||||
response = do_io(global_opts.to, send, no_response)
|
||||
if no_response:
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user