mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-16 19:25:18 +00:00
gst-env: Automatically set the prompt for zsh too
This commit is contained in:
parent
7cbd30eb65
commit
b46aa21ed4
2 changed files with 15 additions and 13 deletions
|
@ -203,15 +203,6 @@ then
|
||||||
PS1+="[ ${GST_ENV} ]"
|
PS1+="[ ${GST_ENV} ]"
|
||||||
fi
|
fi
|
||||||
...
|
...
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
### Zsh prompt
|
|
||||||
|
|
||||||
In your `.zshrc`, you should add something like:
|
|
||||||
|
|
||||||
```
|
|
||||||
export PROMPT="$GST_ENV-$PROMPT"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using powerline
|
### Using powerline
|
||||||
|
|
19
gst-env.py
19
gst-env.py
|
@ -384,6 +384,7 @@ if __name__ == "__main__":
|
||||||
if options.wine:
|
if options.wine:
|
||||||
gst_version += '-' + os.path.basename(options.wine)
|
gst_version += '-' + os.path.basename(options.wine)
|
||||||
|
|
||||||
|
env = get_subprocess_env(options, gst_version)
|
||||||
if not args:
|
if not args:
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
shell = get_windows_shell()
|
shell = get_windows_shell()
|
||||||
|
@ -398,6 +399,7 @@ if __name__ == "__main__":
|
||||||
else:
|
else:
|
||||||
args = [os.environ.get("SHELL", os.path.realpath("/bin/sh"))]
|
args = [os.environ.get("SHELL", os.path.realpath("/bin/sh"))]
|
||||||
if args[0].endswith('bash') and not strtobool(os.environ.get("GST_BUILD_DISABLE_PS1_OVERRIDE", r"FALSE")):
|
if args[0].endswith('bash') and not strtobool(os.environ.get("GST_BUILD_DISABLE_PS1_OVERRIDE", r"FALSE")):
|
||||||
|
# Let the GC remove the tmp file
|
||||||
tmprc = tempfile.NamedTemporaryFile(mode='w')
|
tmprc = tempfile.NamedTemporaryFile(mode='w')
|
||||||
bashrc = os.path.expanduser('~/.bashrc')
|
bashrc = os.path.expanduser('~/.bashrc')
|
||||||
if os.path.exists(bashrc):
|
if os.path.exists(bashrc):
|
||||||
|
@ -405,10 +407,9 @@ if __name__ == "__main__":
|
||||||
shutil.copyfileobj(src, tmprc)
|
shutil.copyfileobj(src, tmprc)
|
||||||
tmprc.write('\nexport PS1="[gst-%s] $PS1"' % gst_version)
|
tmprc.write('\nexport PS1="[gst-%s] $PS1"' % gst_version)
|
||||||
tmprc.flush()
|
tmprc.flush()
|
||||||
# Let the GC remove the tmp file
|
|
||||||
args.append("--rcfile")
|
args.append("--rcfile")
|
||||||
args.append(tmprc.name)
|
args.append(tmprc.name)
|
||||||
if args[0].endswith('fish'):
|
elif args[0].endswith('fish'):
|
||||||
# Ignore SIGINT while using fish as the shell to make it behave
|
# Ignore SIGINT while using fish as the shell to make it behave
|
||||||
# like other shells such as bash and zsh.
|
# like other shells such as bash and zsh.
|
||||||
# See: https://gitlab.freedesktop.org/gstreamer/gst-build/issues/18
|
# See: https://gitlab.freedesktop.org/gstreamer/gst-build/issues/18
|
||||||
|
@ -420,8 +421,18 @@ if __name__ == "__main__":
|
||||||
echo -n '[gst-{}] '(original_fish_prompt)
|
echo -n '[gst-{}] '(original_fish_prompt)
|
||||||
end'''.format(gst_version)
|
end'''.format(gst_version)
|
||||||
args.append(prompt_cmd)
|
args.append(prompt_cmd)
|
||||||
|
elif args[0].endswith('zsh'):
|
||||||
|
tmpdir = tempfile.TemporaryDirectory()
|
||||||
|
# Let the GC remove the tmp file
|
||||||
|
tmprc = open(os.path.join(tmpdir.name, '.zshrc'), 'w')
|
||||||
|
zshrc = os.path.expanduser('~/.zshrc')
|
||||||
|
if os.path.exists(zshrc):
|
||||||
|
with open(zshrc, 'r') as src:
|
||||||
|
shutil.copyfileobj(src, tmprc)
|
||||||
|
tmprc.write('\nexport PROMPT="[gst-{}] $PROMPT"'.format(gst_version))
|
||||||
|
tmprc.flush()
|
||||||
|
env['ZDOTDIR'] = tmpdir.name
|
||||||
try:
|
try:
|
||||||
exit(subprocess.call(args, close_fds=False,
|
exit(subprocess.call(args, close_fds=False, env=env))
|
||||||
env=get_subprocess_env(options, gst_version)))
|
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
exit(e.returncode)
|
exit(e.returncode)
|
||||||
|
|
Loading…
Reference in a new issue