[英]Open gnome-terminal without sourcing .bashrc
Since my .bashrc
contains a lot of aliases, variables and lot of other stuff that changes the behavior of bash, from time to time I want to run gnome-terminal
without sourcing it. 由于我的
.bashrc
包含很多别名,变量和许多其他改变bash行为的东西,我不时想运行gnome-terminal
而不需要它。 I wonder if there's some easy way how to do this without the need to temporarily rename .bashrc
or delete its contents. 我想知道是否有一些简单的方法如何做到这一点,而无需临时重命名
.bashrc
或删除其内容。
You can run bash
without sourcing .bashrc
: 您可以在不使用
.bashrc
情况下运行bash
:
bash --norc
Then it is just a matter of creating a gnome-terminal
profile which runs that bash
command, rather than the default. 然后,只需创建一个运行该
bash
命令的gnome-terminal
配置文件,而不是默认配置文件。
Another option, besides the one already mentioned ( bash --norc
) is a simple evaluation in the beginning of your ~/.bashrc
and skip the rest in case you're running inside a gnome terminal. 除了已经提到的(
bash --norc
)之外,另一个选项是在~/.bashrc
开头的简单评估,如果你在gnome终端内运行,则跳过其余的选项。
For example, you might rely on the fact that other terminal emulators and remote SSH logins as well as local logins from virtual consoles don't set variable COLORTERM
. 例如,您可能依赖于以下事实:其他终端仿真程序和远程SSH登录以及虚拟控制台的本地登录不会设置变量
COLORTERM
。 Armed with this little bit of information you could just wrap everything in your ~/.bashrc
inside a conditional statement: 有了这些信息,您可以将
~/.bashrc
所有内容包装在条件语句中:
if [ "$COLORTERM" != 'gnome-terminal' ]; then
# all your current stuff in ~/.bashrc
fi
That way you don't have to rely to gnome terminal settings, in case you don't want to. 这样你就不必依赖于gnome终端设置,万一你不想这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.