summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xclaessens@netflix.com>2025-10-05 21:44:24 -0400
committerXavier Claessens <xclaesse@gmail.com>2025-10-06 14:47:14 -0400
commit202d15d01b09ebb523d886b98ac668eb666de70d (patch)
treed4edb75f7b91b16dedf91fbb28e524ff823ad3e7
parentd25a7ba2291f9edd7efe88f9f6619748662b2e3e (diff)
downloadmeson-202d15d01b09ebb523d886b98ac668eb666de70d.tar.gz
devenv: Implement prompt for fish and zsh
Co-authored-by: Nirbheek Chauhan <nirbheek@centricular.com>
-rw-r--r--mesonbuild/mdevenv.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/mesonbuild/mdevenv.py b/mesonbuild/mdevenv.py
index bb110c597..344f8d785 100644
--- a/mesonbuild/mdevenv.py
+++ b/mesonbuild/mdevenv.py
@@ -6,6 +6,7 @@ import tempfile
import shutil
import sys
import itertools
+import signal
import typing as T
from pathlib import Path
@@ -232,6 +233,26 @@ def run(options: argparse.Namespace) -> int:
tmprc.flush()
args.append("--rcfile")
args.append(tmprc.name)
+ elif args[0].endswith('fish'):
+ # Ignore SIGINT while using fish as the shell to make it behave
+ # like other shells such as bash and zsh.
+ # See: https://gitlab.freedesktop.org/gstreamer/gst-build/issues/18
+ signal.signal(signal.SIGINT, lambda _, __: True)
+ if prompt_prefix:
+ args.append('--init-command')
+ prompt_cmd = f'''functions --copy fish_prompt original_fish_prompt
+ function fish_prompt
+ echo -n '[{prompt_prefix}] '(original_fish_prompt)
+ end'''
+ args.append(prompt_cmd)
+ elif args[0].endswith('zsh'):
+ # Let the GC remove the tmp file
+ tmpdir = tempfile.TemporaryDirectory()
+ with open(os.path.join(tmpdir.name, '.zshrc'), 'w') as zshrc: # pylint: disable=unspecified-encoding
+ zshrc.write('[ -e ~/.zshrc ] && . ~/.zshrc\n')
+ if prompt_prefix:
+ zshrc.write(f'export PROMPT="[{prompt_prefix}] $PROMPT"\n')
+ devenv['ZDOTDIR'] = tmpdir.name
if 'DYLD_LIBRARY_PATH' in devenv and macos_sip_enabled():
mlog.warning('macOS System Integrity Protection is enabled: DYLD_LIBRARY_PATH cannot be set in the subshell')
mlog.warning('To fix that, use `meson devenv --dump dev.env && source dev.env`')