mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-11 14:45:31 +03:00
macOS: Fix changing tab title and kitty shell not working
I forgot that Apple has its own special snowflake readline variant. Fixes #494
This commit is contained in:
parent
54438cae3f
commit
f68f8bf9c9
@ -53,7 +53,6 @@ def __enter__(self):
|
||||
if os.path.exists(self.history_path):
|
||||
readline.read_history_file(self.history_path)
|
||||
readline.set_completer(self.complete)
|
||||
readline.parse_and_bind('tab: complete')
|
||||
return self
|
||||
|
||||
def __exit__(self, *a):
|
||||
@ -87,6 +86,7 @@ def main(args):
|
||||
global readline
|
||||
import readline as rl
|
||||
readline = rl
|
||||
from kitty.shell import init_readline
|
||||
msg = 'Ask the user for input'
|
||||
try:
|
||||
args, items = parse_args(args[1:], option_text, '', msg, 'kitty ask')
|
||||
@ -96,7 +96,7 @@ def main(args):
|
||||
input('Press enter to quit...')
|
||||
raise SystemExit(e.code)
|
||||
|
||||
readline.read_init_file()
|
||||
init_readline(readline)
|
||||
ans = {'items': items}
|
||||
|
||||
with alternate_screen(), HistoryCompleter(args.name):
|
||||
|
@ -14,12 +14,24 @@
|
||||
emph, green, italic, parse_option_spec, print_help_for_seq, title
|
||||
)
|
||||
from .cmds import cmap, display_subcommand_help, parse_subcommand_cli
|
||||
from .constants import cache_dir, version
|
||||
from .constants import cache_dir, is_macos, version
|
||||
|
||||
all_commands = tuple(sorted(cmap))
|
||||
match_commands = tuple(sorted(all_commands + ('exit', 'help', 'quit')))
|
||||
|
||||
|
||||
def init_readline(readline):
|
||||
try:
|
||||
readline.read_init_file()
|
||||
except EnvironmentError:
|
||||
if not is_macos:
|
||||
raise
|
||||
if 'libedit' in readline.__doc__:
|
||||
readline.parse_and_bind("bind ^I rl_complete")
|
||||
else:
|
||||
readline.parse_and_bind('tab: complete')
|
||||
|
||||
|
||||
def cmd_names_matching(prefix):
|
||||
for cmd in match_commands:
|
||||
if not prefix or cmd.startswith(prefix):
|
||||
@ -76,7 +88,6 @@ def __enter__(self):
|
||||
if os.path.exists(self.history_path):
|
||||
readline.read_history_file(self.history_path)
|
||||
readline.set_completer(self.complete)
|
||||
readline.parse_and_bind('tab: complete')
|
||||
delims = readline.get_completer_delims()
|
||||
readline.set_completer_delims(delims.replace('-', ''))
|
||||
return self
|
||||
@ -141,7 +152,7 @@ def run_cmd(global_opts, cmd, func, opts, items):
|
||||
|
||||
|
||||
def real_main(global_opts):
|
||||
readline.read_init_file()
|
||||
init_readline(readline)
|
||||
print_help_for_seq.allow_pager = False
|
||||
print('Welcome to the kitty shell!')
|
||||
print('Use {} for assistance or {} to quit'.format(green('help'), green('exit')))
|
||||
|
Loading…
Reference in New Issue
Block a user