mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-04 15:51:15 -03:00
Move sample_prompts/themes to share/
They are used by "fish_config" CLI too, so no need to make them private to webconfig. Putting them at top-level seems simpler overall.
This commit is contained in:
@@ -95,8 +95,8 @@ fish_create_dirs(${rel_datadir}/fish ${rel_datadir}/fish/completions
|
|||||||
${rel_datadir}/fish/man/man1 ${rel_datadir}/fish/tools
|
${rel_datadir}/fish/man/man1 ${rel_datadir}/fish/tools
|
||||||
${rel_datadir}/fish/tools/web_config
|
${rel_datadir}/fish/tools/web_config
|
||||||
${rel_datadir}/fish/tools/web_config/js
|
${rel_datadir}/fish/tools/web_config/js
|
||||||
${rel_datadir}/fish/tools/web_config/sample_prompts
|
${rel_datadir}/fish/prompts
|
||||||
${rel_datadir}/fish/tools/web_config/themes
|
${rel_datadir}/fish/themes
|
||||||
)
|
)
|
||||||
|
|
||||||
configure_file(share/__fish_build_paths.fish.in share/__fish_build_paths.fish)
|
configure_file(share/__fish_build_paths.fish.in share/__fish_build_paths.fish)
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ Files: share/tools/web_config/js/alpine.js
|
|||||||
Copyright: 2019-2021 Caleb Porzio and contributors
|
Copyright: 2019-2021 Caleb Porzio and contributors
|
||||||
License: MIT
|
License: MIT
|
||||||
|
|
||||||
Files: share/tools/web_config/themes/Dracula.theme
|
Files: share/themes/Dracula.theme
|
||||||
Copyright: 2018 Dracula Team
|
Copyright: 2018 Dracula Team
|
||||||
License: MIT
|
License: MIT
|
||||||
|
|
||||||
Files: share/tools/web_config/themes/Nord.theme
|
Files: share/themes/Nord.theme
|
||||||
Copyright: 2016-2024 Sven Greb
|
Copyright: 2016-2024 Sven Greb
|
||||||
License: MIT
|
License: MIT
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ function __fish_theme_cat -a theme_name
|
|||||||
set -l theme_path (__fish_theme_paths $theme_name)[1]
|
set -l theme_path (__fish_theme_paths $theme_name)[1]
|
||||||
if not set -q theme_path[1]
|
if not set -q theme_path[1]
|
||||||
echo >&2 "No such theme: $theme_name"
|
echo >&2 "No such theme: $theme_name"
|
||||||
echo >&2 Searched (__fish_theme_dir) "and `status list-files tools/web_config/themes`"
|
echo >&2 Searched (__fish_theme_dir) "and `status list-files themes`"
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
__fish_data_with_file $theme_path cat
|
__fish_data_with_file $theme_path cat
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# localization: skip(private)
|
# localization: skip(private)
|
||||||
function __fish_theme_paths
|
function __fish_theme_paths
|
||||||
__fish_config_files --user-dir=(__fish_theme_dir) \
|
__fish_config_files --user-dir=(__fish_theme_dir) \
|
||||||
tools/web_config/themes .theme $argv
|
themes .theme $argv
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ end
|
|||||||
|
|
||||||
function __fish_config_list_prompts
|
function __fish_config_list_prompts
|
||||||
set -lx dir
|
set -lx dir
|
||||||
set -l prompt_paths (__fish_config_files tools/web_config/sample_prompts .fish $argv)
|
set -l prompt_paths (__fish_config_files prompts .fish $argv)
|
||||||
if [ (count $argv) = 1 ] && set -q prompt_paths[2]
|
if [ (count $argv) = 1 ] && set -q prompt_paths[2]
|
||||||
echo >&2 "fish_config: internal error: multiple prompts matching '$argv' ??"
|
echo >&2 "fish_config: internal error: multiple prompts matching '$argv' ??"
|
||||||
set --erase prompt_paths[2..]
|
set --erase prompt_paths[2..]
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ def is_chromeos_garcon():
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def run_fish_cmd(text):
|
def run_fish_cmd(text, strict=False):
|
||||||
print("$ " + text)
|
print("$ " + text)
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
[FISH_BIN_PATH],
|
[FISH_BIN_PATH],
|
||||||
@@ -108,9 +108,27 @@ def run_fish_cmd(text):
|
|||||||
out, err = p.communicate(text.encode("utf-8"))
|
out, err = p.communicate(text.encode("utf-8"))
|
||||||
out = out.decode("utf-8", "replace")
|
out = out.decode("utf-8", "replace")
|
||||||
err = err.decode("utf-8", "replace")
|
err = err.decode("utf-8", "replace")
|
||||||
|
if strict:
|
||||||
|
assert err == ""
|
||||||
|
# TODO use check_output()
|
||||||
|
return out
|
||||||
return out, err
|
return out, err
|
||||||
|
|
||||||
|
|
||||||
|
def list_embedded_files(path, suffix):
|
||||||
|
return [
|
||||||
|
path
|
||||||
|
for path in run_fish_cmd(
|
||||||
|
"status list-files " + escape_fish_cmd(path), strict=True
|
||||||
|
).splitlines()
|
||||||
|
if path.endswith(suffix)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def get_embedded_file(path):
|
||||||
|
return run_fish_cmd("status get-file " + escape_fish_cmd(path), strict=True)
|
||||||
|
|
||||||
|
|
||||||
def escape_fish_cmd(text):
|
def escape_fish_cmd(text):
|
||||||
# Replace one backslash with two, and single quotes with backslash-quote
|
# Replace one backslash with two, and single quotes with backslash-quote
|
||||||
escaped = text.replace("\\", "\\\\").replace("'", "\\'")
|
escaped = text.replace("\\", "\\\\").replace("'", "\\'")
|
||||||
@@ -764,8 +782,7 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||||||
if not path:
|
if not path:
|
||||||
out, err = run_fish_cmd("fish_config theme dump")
|
out, err = run_fish_cmd("fish_config theme dump")
|
||||||
else:
|
else:
|
||||||
with open(path) as f:
|
out = get_embedded_file(path)
|
||||||
out = f.read()
|
|
||||||
|
|
||||||
info = {}
|
info = {}
|
||||||
colors = []
|
colors = []
|
||||||
@@ -1018,32 +1035,30 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||||||
|
|
||||||
def read_one_sample_prompt(self, path):
|
def read_one_sample_prompt(self, path):
|
||||||
try:
|
try:
|
||||||
with open(path, "rb") as fd:
|
extras_dict = {}
|
||||||
extras_dict = {}
|
# Read one sample prompt from out
|
||||||
# Read one sample prompt from fd
|
function_lines = []
|
||||||
function_lines = []
|
parsing_hashes = True
|
||||||
parsing_hashes = True
|
for line in get_embedded_file(path).splitlines(keepends=True):
|
||||||
unicode_lines = (line.decode("utf-8") for line in fd)
|
# Parse hashes until parse_one_sample_prompt_hash return
|
||||||
for line in unicode_lines:
|
# False.
|
||||||
# Parse hashes until parse_one_sample_prompt_hash return
|
if parsing_hashes:
|
||||||
# False.
|
parsing_hashes = self.parse_one_sample_prompt_hash(
|
||||||
if parsing_hashes:
|
line, extras_dict
|
||||||
parsing_hashes = self.parse_one_sample_prompt_hash(
|
)
|
||||||
line, extras_dict
|
# Maybe not we're not parsing hashes, or maybe we already
|
||||||
)
|
# were not.
|
||||||
# Maybe not we're not parsing hashes, or maybe we already
|
if not parsing_hashes:
|
||||||
# were not.
|
function_lines.append(line)
|
||||||
if not parsing_hashes:
|
func = "".join(function_lines).strip()
|
||||||
function_lines.append(line)
|
result = self.do_get_sample_prompt(func, extras_dict)
|
||||||
func = "".join(function_lines).strip()
|
return result
|
||||||
result = self.do_get_sample_prompt(func, extras_dict)
|
|
||||||
return result
|
|
||||||
except IOError:
|
except IOError:
|
||||||
# Ignore unreadable files, etc.
|
# Ignore unreadable files, etc.
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def do_get_sample_prompts_list(self):
|
def do_get_sample_prompts_list(self):
|
||||||
paths = sorted(glob.iglob("sample_prompts/*.fish"))
|
paths = list_embedded_files("prompts", ".fish")
|
||||||
result = []
|
result = []
|
||||||
try:
|
try:
|
||||||
pool = multiprocessing.pool.ThreadPool(processes=8)
|
pool = multiprocessing.pool.ThreadPool(processes=8)
|
||||||
@@ -1120,7 +1135,7 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||||||
else os.path.expanduser("~")
|
else os.path.expanduser("~")
|
||||||
)
|
)
|
||||||
paths = list(glob.iglob(os.path.join(confighome, "fish", "themes/*.theme")))
|
paths = list(glob.iglob(os.path.join(confighome, "fish", "themes/*.theme")))
|
||||||
paths.extend(list(glob.iglob("themes/*.theme")))
|
paths.extend(list_embedded_files("themes", ".theme"))
|
||||||
paths.sort(key=str.casefold)
|
paths.sort(key=str.casefold)
|
||||||
|
|
||||||
for p in paths:
|
for p in paths:
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ type fish_mode_prompt
|
|||||||
|
|
||||||
fish_config theme choose non-existent-theme1
|
fish_config theme choose non-existent-theme1
|
||||||
# CHECKERR: No such theme: non-existent-theme1
|
# CHECKERR: No such theme: non-existent-theme1
|
||||||
# CHECKERR: Searched {{/\S* (/\S*|and `status list-files tools/web_config/themes`)}}
|
# CHECKERR: Searched {{/\S* (/\S*|and `status list-files themes`)}}
|
||||||
|
|
||||||
# This still demos the current theme.
|
# This still demos the current theme.
|
||||||
fish_config theme show non-existent-theme2
|
fish_config theme show non-existent-theme2
|
||||||
@@ -156,7 +156,7 @@ fish_config theme show | grep -E '[^-]default|base16-default-dark|custom-from-us
|
|||||||
# CHECK: {{.*}}default{{\x1b\[m}}
|
# CHECK: {{.*}}default{{\x1b\[m}}
|
||||||
|
|
||||||
# Override a default theme with different colors.
|
# Override a default theme with different colors.
|
||||||
__fish_data_with_file tools/web_config/themes/none.theme \
|
__fish_data_with_file themes/none.theme \
|
||||||
cat >$__fish_config_dir/themes/default.theme
|
cat >$__fish_config_dir/themes/default.theme
|
||||||
fish_config theme show | grep -E '[^-]default|base16-default-dark' -A1
|
fish_config theme show | grep -E '[^-]default|base16-default-dark' -A1
|
||||||
# CHECK: {{\x1b\[m}}{{\x1b\[4m}}default{{\x1b\[m}}
|
# CHECK: {{\x1b\[m}}{{\x1b\[4m}}default{{\x1b\[m}}
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
prompt_pwd -d 1 /foo/bar/baz
|
prompt_pwd -d 1 /foo/bar/baz
|
||||||
# CHECK: /f/b/baz
|
# CHECK: /f/b/baz
|
||||||
|
|
||||||
prompt_pwd /usr/share/fish/tools/web_config/sample_prompts
|
prompt_pwd /usr/share/fish/prompts
|
||||||
# CHECK: /u/s/f/t/w/sample_prompts
|
# CHECK: /u/s/f/prompts
|
||||||
|
|
||||||
prompt_pwd -D 2 /usr/share/fish/tools/web_config/sample_prompts
|
prompt_pwd -D 2 /usr/share/fish/prompts
|
||||||
# CHECK: /u/s/f/t/web_config/sample_prompts
|
# CHECK: /u/s/fish/prompts
|
||||||
|
|
||||||
prompt_pwd -D 0 /usr/share/fish/tools/web_config/sample_prompts
|
prompt_pwd -D 0 /usr/share/fish/prompts
|
||||||
# CHECK: /u/s/f/t/w/s
|
# CHECK: /u/s/f/p
|
||||||
|
|
||||||
prompt_pwd -d1 -D 3 /usr/share/fish/tools/web_config/-sample_prompts
|
prompt_pwd -d1 -D 3 /usr/local/share/fish/prompts
|
||||||
# CHECK: /u/s/f/tools/web_config/-sample_prompts
|
# CHECK: /u/l/share/fish/prompts
|
||||||
|
|||||||
Reference in New Issue
Block a user