Expand ~ and env vars in program names. Fixes #483
This commit is contained in:
parent
92ca8ab9cc
commit
edc4b91d15
@ -15,7 +15,8 @@ from .cli import create_opts, parse_args
|
||||
from .config import (
|
||||
MINIMUM_FONT_SIZE, initial_window_size, prepare_config_file_for_editing
|
||||
)
|
||||
from .constants import appname, editor, set_boss, config_dir
|
||||
from .config_utils import to_cmdline
|
||||
from .constants import appname, config_dir, editor, set_boss
|
||||
from .fast_data_types import (
|
||||
ChildMonitor, create_os_window, current_os_window, destroy_global_data,
|
||||
destroy_sprite_map, get_clipboard_string, glfw_post_empty_event,
|
||||
@ -562,6 +563,8 @@ class Boss:
|
||||
|
||||
def open_url(self, url, program=None):
|
||||
if url:
|
||||
if isinstance(program, str):
|
||||
program = to_cmdline(program)
|
||||
open_url(url, program or self.opts.open_url_with)
|
||||
|
||||
def open_url_lines(self, lines, program=None):
|
||||
|
||||
@ -6,7 +6,6 @@ import ast
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import sys
|
||||
import tempfile
|
||||
from collections import namedtuple
|
||||
@ -15,7 +14,7 @@ from contextlib import contextmanager
|
||||
from . import fast_data_types as defines
|
||||
from .config_utils import (
|
||||
init_config, load_config as _load_config, merge_dicts, parse_config_base,
|
||||
positive_float, positive_int, to_bool, to_color, unit_float
|
||||
positive_float, positive_int, to_bool, to_cmdline, to_color, unit_float
|
||||
)
|
||||
from .constants import cache_dir, defconf
|
||||
from .fast_data_types import CURSOR_BEAM, CURSOR_BLOCK, CURSOR_UNDERLINE
|
||||
@ -119,7 +118,7 @@ def parse_key_action(action):
|
||||
elif func == 'set_font_size':
|
||||
args = (float(rest),)
|
||||
elif func in shlex_actions:
|
||||
args = shlex.split(rest)
|
||||
args = to_cmdline(rest)
|
||||
return KeyAction(func, args)
|
||||
|
||||
|
||||
@ -292,7 +291,8 @@ type_map = {
|
||||
'adjust_line_height': adjust_line_height,
|
||||
'adjust_column_width': adjust_line_height,
|
||||
'scrollback_lines': positive_int,
|
||||
'scrollback_pager': shlex.split,
|
||||
'scrollback_pager': to_cmdline,
|
||||
'open_url_with': to_cmdline,
|
||||
'font_size': to_font_size,
|
||||
'font_size_delta': positive_float,
|
||||
'focus_follows_mouse': to_bool,
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
|
||||
from .rgb import to_color as as_color
|
||||
from .utils import log_error
|
||||
@ -31,6 +32,12 @@ def to_bool(x):
|
||||
return x.lower() in 'y yes true'.split()
|
||||
|
||||
|
||||
def to_cmdline(x):
|
||||
ans = shlex.split(x)
|
||||
ans[0] = os.path.expandvars(os.path.expanduser(ans[0]))
|
||||
return ans
|
||||
|
||||
|
||||
def parse_line(line, type_map, special_handling, ans, all_keys, base_path_for_includes):
|
||||
line = line.strip()
|
||||
if not line or line.startswith('#'):
|
||||
|
||||
@ -8,7 +8,6 @@ import fcntl
|
||||
import math
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import socket
|
||||
import string
|
||||
import subprocess
|
||||
@ -111,10 +110,11 @@ def base64_encode(
|
||||
|
||||
|
||||
def command_for_open(program='default'):
|
||||
if program == 'default':
|
||||
if isinstance(program, str):
|
||||
from .config_utils import to_cmdline
|
||||
program = to_cmdline(program)
|
||||
if program == ['default']:
|
||||
cmd = ['open'] if is_macos else ['xdg-open']
|
||||
else:
|
||||
cmd = shlex.split(program)
|
||||
return cmd
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user