Add a facility to specify command line arguments when running kitty from the GUI on macOS
Fixes #395
This commit is contained in:
parent
64b48945d4
commit
b2561fd61e
@ -511,6 +511,20 @@ Really, the correct solution for this is to convince the OpenSSH maintainers to
|
|||||||
have ssh do this automatically when connecting to a server, so that all
|
have ssh do this automatically when connecting to a server, so that all
|
||||||
terminals work transparently.
|
terminals work transparently.
|
||||||
|
|
||||||
|
|
||||||
|
=== How do I specify command line options for kitty on macOS?
|
||||||
|
|
||||||
|
Apple does not want you to use command line options with GUI applications. To
|
||||||
|
workaround that limitation, kitty will read command line options from the file
|
||||||
|
`~/Library/Preferences/kitty/macos-launch-services-cmdline` when it is launched
|
||||||
|
from the GUI, i.e. by clicking the kitty application icon or using `open -a kitty`.
|
||||||
|
|
||||||
|
You can, of course, also run kitty from a terminal with command line options, using:
|
||||||
|
`/Applications/kitty.app/Contents/MacOS/kitty`.
|
||||||
|
|
||||||
|
And within kitty itself, you can always run kitty using just `kitty` as it
|
||||||
|
cleverly adds itself to the PATH.
|
||||||
|
|
||||||
== Resources on terminal behavior
|
== Resources on terminal behavior
|
||||||
|
|
||||||
http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
|
http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
|
||||||
|
|||||||
@ -11,7 +11,7 @@ from .borders import load_borders_program
|
|||||||
from .boss import Boss
|
from .boss import Boss
|
||||||
from .cli import create_opts, parse_args
|
from .cli import create_opts, parse_args
|
||||||
from .config import cached_values_for, initial_window_size
|
from .config import cached_values_for, initial_window_size
|
||||||
from .constants import appname, glfw_path, is_macos, is_wayland, logo_data_file
|
from .constants import appname, glfw_path, is_macos, is_wayland, logo_data_file, config_dir
|
||||||
from .fast_data_types import (
|
from .fast_data_types import (
|
||||||
create_os_window, glfw_init, glfw_terminate, set_default_window_icon,
|
create_os_window, glfw_init, glfw_terminate, set_default_window_icon,
|
||||||
set_options, show_window
|
set_options, show_window
|
||||||
@ -92,6 +92,20 @@ def setup_profiling(args):
|
|||||||
print('To view the graphical call data, use: kcachegrind', cg)
|
print('To view the graphical call data, use: kcachegrind', cg)
|
||||||
|
|
||||||
|
|
||||||
|
def macos_cmdline():
|
||||||
|
try:
|
||||||
|
with open(os.path.join(config_dir, 'macos-launch-services-cmdline')) as f:
|
||||||
|
raw = f.read()
|
||||||
|
except FileNotFoundError:
|
||||||
|
return []
|
||||||
|
import shlex
|
||||||
|
raw = raw.strip()
|
||||||
|
ans = shlex.split(raw)
|
||||||
|
if ans and ans[0] == 'kitty':
|
||||||
|
del ans[0]
|
||||||
|
return ans
|
||||||
|
|
||||||
|
|
||||||
def _main():
|
def _main():
|
||||||
try:
|
try:
|
||||||
sys.setswitchinterval(1000.0) # we have only a single python thread
|
sys.setswitchinterval(1000.0) # we have only a single python thread
|
||||||
@ -123,11 +137,13 @@ def _main():
|
|||||||
if rpath and rpath not in items:
|
if rpath and rpath not in items:
|
||||||
os.environ['PATH'] += os.pathsep + rpath
|
os.environ['PATH'] += os.pathsep + rpath
|
||||||
|
|
||||||
if os.environ.pop('KITTY_LAUNCHED_BY_LAUNCH_SERVICES', None) == '1':
|
args = sys.argv[1:]
|
||||||
|
if is_macos and os.environ.pop('KITTY_LAUNCHED_BY_LAUNCH_SERVICES', None) == '1':
|
||||||
os.chdir(os.path.expanduser('~'))
|
os.chdir(os.path.expanduser('~'))
|
||||||
|
args = macos_cmdline()
|
||||||
if not os.path.isdir(os.getcwd()):
|
if not os.path.isdir(os.getcwd()):
|
||||||
os.chdir(os.path.expanduser('~'))
|
os.chdir(os.path.expanduser('~'))
|
||||||
args, rest = parse_args()
|
args, rest = parse_args(args=args)
|
||||||
args.args = rest
|
args.args = rest
|
||||||
if getattr(args, 'detach', False):
|
if getattr(args, 'detach', False):
|
||||||
detach()
|
detach()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user