Add prompt support for fish. (#47609)

To avoid changing the fish_prompt function, create a SPACK_PROMPT
environment variable, which users can then manually incorporate into
their fish_prompt.fish function.
This commit is contained in:
Aaron Young 2024-11-14 18:14:44 -05:00 committed by GitHub
parent f5fef81779
commit 88b5a12e16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -64,9 +64,10 @@ def deactivate_header(shell):
elif shell == "fish": elif shell == "fish":
cmds += "set -e SPACK_ENV;\n" cmds += "set -e SPACK_ENV;\n"
cmds += "set -e SPACK_ENV_VIEW;\n" cmds += "set -e SPACK_ENV_VIEW;\n"
cmds += "set -e SPACK_PROMPT;\n"
cmds += "functions -e despacktivate;\n" cmds += "functions -e despacktivate;\n"
# #
# NOTE: Not changing fish_prompt (above) => no need to restore it here. # NOTE: Unsetting SPACK_PROMPT environment variable which is used to avoid changing fish_prompt function.
# #
elif shell == "bat": elif shell == "bat":
# TODO: Color # TODO: Color

View File

@ -42,7 +42,8 @@ def custom_prompt(prompt, shell):
cmds += 'set prompt="%s ${prompt}";\n' % prompt cmds += 'set prompt="%s ${prompt}";\n' % prompt
elif shell == "fish": elif shell == "fish":
if "color" in os.getenv("TERM", ""): if "color" in os.getenv("TERM", ""):
prompt = colorize(f"@G{prompt} " % prompt, color=True) prompt = colorize(f"@G{prompt}", color=True)
cmds += "set -gx SPACK_PROMPT '%s';\n" % prompt
elif shell == "bat" or shell == "pwsh": elif shell == "bat" or shell == "pwsh":
# TODO # TODO
pass pass