如何获取自定义的Gnu Screen配置来加载.bash_profile和.bash_aliases?

3

我有一个自定义的屏幕配置myscreenconfig和一个.screenrc文件。 myscreenconfig看起来像这样:

source .screenrc
screen 0 bash
title 'notes' 
screen 1 bash
title 'bash' 
[etc.]

.screenrc 文件顶部有以下几行内容:

altscreen on
shell -${SHELL}

我的.bash_profile文件设置了很多内容,然后调用source $HOME/.bash_aliases

如果我不带任何参数启动screen,我的.bash_profile.bash_aliases都会加载。但是,如果我通过screen -c myscreenconfig来启动screen,则只有.bash_profile被加载,而没有加载.bash_aliases。为什么?如何解决这个问题?


虽然已经回答了,但这个问题应该放在ServerFault上讨论... - Frank V
4个回答

3

对我而言有效的方法是在我的bash设置和.bashrc之间建立符号链接(我没有这个文件):

ln -s ~/.bash_profile ~/.bashrc

2

我在使用的一台机器上也遇到了同样的问题。在阅读了上面关于链接两个bash资源文件的建议后,我意识到在这台特定的机器上,以下部分已经被注释在.bash_profile文件中:

# Get the aliases and functions
# if [ -f ~/.bashrc ]; then
#    . ~/.bashrc
# fi

if块行的前面移除注释符号(#)后,.bashrc中的设置也可在screen会话中使用。

0

因为在 myscreenconfig 中没有使用登录 shell。 使用(如果我没记错)screen 0 -bash,或尝试与 deflogin on 的组合。


0

我在我的 .bashrc 文件中使用了这个。

if [ "$TERM" = "screen" ]; then
        if [ -f ~/.bash_profile ]; then
                . ~/.bash_profile
        fi
fi

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接