Allow using @selection in the launch cmdline
This commit is contained in:
parent
059786ab66
commit
ad2bd1bf63
@ -249,7 +249,9 @@ def write_cli_docs(all_kitten_names):
|
||||
f.write(option_spec_as_rst(
|
||||
appname='launch', ospec=launch_options_spec, heading_char='_',
|
||||
message='''\
|
||||
Launch an arbitrary program in a new kitty window/tab
|
||||
Launch an arbitrary program in a new kitty window/tab. Note that
|
||||
if you specify a program-to-run you can use the special placeholder
|
||||
:code:`@selection` which will be replaced by the current selection.
|
||||
'''
|
||||
))
|
||||
with open('generated/cli-kitty.rst', 'w') as f:
|
||||
|
||||
@ -896,6 +896,9 @@ class Boss:
|
||||
stdin = stdin.encode('utf-8')
|
||||
return env, stdin
|
||||
|
||||
def data_for_at(self, which, window=None, add_wrap_markers=False):
|
||||
return data_for_at(window or self.active_window, which, add_wrap_markers=add_wrap_markers)
|
||||
|
||||
def special_window_for_cmd(self, cmd, window=None, stdin=None, cwd_from=None, as_overlay=False):
|
||||
w = window or self.active_window
|
||||
env, stdin = self.process_stdin_source(w, stdin)
|
||||
|
||||
@ -164,7 +164,14 @@ def launch(boss, opts, args):
|
||||
if opts.copy_cmdline and active_child:
|
||||
cmd = active_child.foreground_cmdline
|
||||
if cmd:
|
||||
kw['cmd'] = cmd
|
||||
final_cmd = []
|
||||
for x in cmd:
|
||||
if x == '@selection' and active and not opts.copy_cmdline:
|
||||
s = boss.data_for_at(active, x)
|
||||
if s:
|
||||
x = s
|
||||
final_cmd.append(x)
|
||||
kw['cmd'] = final_cmd
|
||||
if opts.type == 'overlay' and active and not active.overlay_window_id:
|
||||
kw['overlay_for'] = active.id
|
||||
if opts.stdin_source:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user