mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-18 14:34:52 +02:00
Allow using - as a synonym for /dev/stdin when reading the config
This commit is contained in:
@@ -43,7 +43,8 @@ directory is always used and the above searching does not happen.
|
|||||||
|
|
||||||
If :file:`/etc/xdg/{appname}/{conf_name}.conf` exists it is merged before (i.e. with lower
|
If :file:`/etc/xdg/{appname}/{conf_name}.conf` exists it is merged before (i.e. with lower
|
||||||
priority) than any user config files. It can be used to specify system-wide
|
priority) than any user config files. It can be used to specify system-wide
|
||||||
defaults for all users.
|
defaults for all users. You can use either :code:`-` or :code:`/dev/stdin` to read the
|
||||||
|
config from STDIN.
|
||||||
'''.replace(
|
'''.replace(
|
||||||
'{macos_confpath}',
|
'{macos_confpath}',
|
||||||
(':file:`~/Library/Preferences/{appname}/{conf_name}.conf`,' if is_macos else ''), 1
|
(':file:`~/Library/Preferences/{appname}/{conf_name}.conf`,' if is_macos else ''), 1
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
|
import sys
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from typing import (
|
from typing import (
|
||||||
Any, Callable, Dict, Generator, Generic, Iterable, Iterator, List,
|
Any, Callable, Dict, Generator, Generic, Iterable, Iterator, List,
|
||||||
@@ -261,12 +262,17 @@ def load_config(
|
|||||||
for path in paths:
|
for path in paths:
|
||||||
if not path:
|
if not path:
|
||||||
continue
|
continue
|
||||||
try:
|
if path == '-':
|
||||||
with open(path, encoding='utf-8', errors='replace') as f:
|
path = '/dev/stdin'
|
||||||
with currently_parsing.set_file(path):
|
with currently_parsing.set_file(path):
|
||||||
vals = parse_config(f)
|
vals = parse_config(sys.stdin)
|
||||||
except (FileNotFoundError, PermissionError):
|
else:
|
||||||
continue
|
try:
|
||||||
|
with open(path, encoding='utf-8', errors='replace') as f:
|
||||||
|
with currently_parsing.set_file(path):
|
||||||
|
vals = parse_config(f)
|
||||||
|
except (FileNotFoundError, PermissionError):
|
||||||
|
continue
|
||||||
found_paths.append(path)
|
found_paths.append(path)
|
||||||
ans = merge_configs(ans, vals)
|
ans = merge_configs(ans, vals)
|
||||||
if overrides is not None:
|
if overrides is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user