在猛砸父Shell改变PS1提示 [英] Changing PS1 prompt in a Bash parent shell

查看:131
本文介绍了在猛砸父Shell改变PS1提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用脚本,我是改变母体的Bash shell的提示。我曾尝试以下内容:

Using a script, I was to change the prompt of the parent Bash shell. I have tried the following:

PS1="Hello World > "

这改变了子shell,该脚本的运行中的提示,但该命令我会用改变父shell的提示。任何想法?

This changes the prompt of the subshell, which the script is running in, but which command would I use to change the prompt of the parent shell. Any ideas?

推荐答案

在所有情况下,父shell必须合作。没有它的合作在UNIX环境下的子进程不能影响父进程。

In all cases the parent shell must cooperate. The child process in a unix environment cannot influence the parent process without its cooperation.

试试这个 changePrompt.sh

echo 'PS1="Hello World > "'

然后再从这样的父shell调用脚本:

And then call the script from the parent shell like this:

eval "$(changePrompt.sh)"

或者,不同的方法:源脚本,而不是调用它。 changePrompt.sh

PS1="Hello World > "

这样称呼它:

source changePrompt.sh

或者只是:

. changePrompt.sh

这篇关于在猛砸父Shell改变PS1提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆