我的~/.bashrc
:https : //pastebin.com/VA7RLA2E
我的~/.Xresources
:https : //pastebin.com/qSF1z0w4
如何让 XTerm.bashrc
在启动时自动获取?目前,每当我打开一个新的 XTerm 窗口时,它都不会提供~/.bashrc
.
我的操作系统是 Ubuntu 18.04。
在您的~/.Xresources
文件中,您有一行
xterm*loginShell: true
Run Code Online (Sandbox Code Playgroud)
这将使 XTerm 作为登录 shell 启动 shell 会话。当bash
作为登录 shell 运行时,它会读取您的~/.bash_profile
文件,但不会读取~/.bashrc
(此文件由非登录交互会话~/.bash_profile
读取),除非source
显式读取它。
您有两个选择:
~/.Xresources
指定 shell 应该是登录 shell 的行。您可能必须退出图形登录会话才能重新读取此文件并使更改生效。使您的~/.bash_profile
文件成为source
您的~/.bashrc
文件,同时确保您的~/.bashrc
文件不会同时获取~/.bash_profile
文件(这会造成无限循环)。
如何执行此操作的示例(这将添加到~/.bash_profile
文件中):
if [ -o interactive ] && [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
Run Code Online (Sandbox Code Playgroud)
如果您的系统尚未完成,您可能需要为/etc/profile
vs/etc/bash.bashrc
或系统上的任何位置执行类似的bashrc
操作。然而,正如/etc/profile
所有类似 Bourne 的 shell 所读到的,不仅仅是bash
,它需要稍微调整一下:
if [ -n "$BASH" ] &&
[ "$BASH" != /bin/sh ] &&
[ -o interactive ] &&
[ ! -o posix ] &&
[ -f /etc/bash.bashrc ]
then
source /etc/bash.bashrc
fi
Run Code Online (Sandbox Code Playgroud) 归档时间: |
|
查看次数: |
2810 次 |
最近记录: |