Nicer error message when trying to open the config file and no editor is available
This commit is contained in:
parent
bcd78c3940
commit
1c44da2b4a
@ -1522,9 +1522,7 @@ class Boss:
|
|||||||
@ac('misc', 'Edit the kitty.conf config file in your favorite text editor')
|
@ac('misc', 'Edit the kitty.conf config file in your favorite text editor')
|
||||||
def edit_config_file(self, *a: Any) -> None:
|
def edit_config_file(self, *a: Any) -> None:
|
||||||
confpath = prepare_config_file_for_editing()
|
confpath = prepare_config_file_for_editing()
|
||||||
# On macOS vim fails to handle SIGWINCH if it occurs early, so add a
|
cmd = [kitty_exe(), '+edit'] + get_editor(get_options()) + [confpath]
|
||||||
# small delay.
|
|
||||||
cmd = [kitty_exe(), '+runpy', 'import os, sys, time; time.sleep(0.05); os.execvp(sys.argv[1], sys.argv[1:])'] + get_editor(get_options()) + [confpath]
|
|
||||||
self.new_os_window(*cmd)
|
self.new_os_window(*cmd)
|
||||||
|
|
||||||
def run_kitten_with_metadata(
|
def run_kitten_with_metadata(
|
||||||
|
|||||||
@ -81,6 +81,25 @@ def launch(args: List[str]) -> None:
|
|||||||
runpy.run_path(exe, run_name='__main__')
|
runpy.run_path(exe, run_name='__main__')
|
||||||
|
|
||||||
|
|
||||||
|
def edit(args: List[str]) -> None:
|
||||||
|
import shutil
|
||||||
|
from .constants import is_macos
|
||||||
|
if is_macos:
|
||||||
|
# On macOS vim fails to handle SIGWINCH if it occurs early, so add a small delay.
|
||||||
|
import time
|
||||||
|
time.sleep(0.05)
|
||||||
|
exe = args[1]
|
||||||
|
if not os.path.isabs(exe):
|
||||||
|
exe = shutil.which(exe) or ''
|
||||||
|
if not exe or not os.access(exe, os.X_OK):
|
||||||
|
print('Cannot find an editor on your system. Set the \x1b[33meditor\x1b[39m value in kitty.conf'
|
||||||
|
' to the absolute path of your editor of choice.', file=sys.stderr)
|
||||||
|
from kitty.utils import hold_till_enter
|
||||||
|
hold_till_enter()
|
||||||
|
raise SystemExit(1)
|
||||||
|
os.execv(exe, args[1:])
|
||||||
|
|
||||||
|
|
||||||
def shebang(args: List[str]) -> None:
|
def shebang(args: List[str]) -> None:
|
||||||
script_path = args[1]
|
script_path = args[1]
|
||||||
cmd = args[2:]
|
cmd = args[2:]
|
||||||
@ -152,6 +171,7 @@ namespaced_entry_points['open'] = open_urls
|
|||||||
namespaced_entry_points['kitten'] = run_kitten
|
namespaced_entry_points['kitten'] = run_kitten
|
||||||
namespaced_entry_points['edit-config'] = edit_config_file
|
namespaced_entry_points['edit-config'] = edit_config_file
|
||||||
namespaced_entry_points['shebang'] = shebang
|
namespaced_entry_points['shebang'] = shebang
|
||||||
|
namespaced_entry_points['edit'] = edit
|
||||||
|
|
||||||
|
|
||||||
def setup_openssl_environment(ext_dir: str) -> None:
|
def setup_openssl_environment(ext_dir: str) -> None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user