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

发布于 2024-10-10 14:34:36 字数 615 浏览 0 评论 0原文

我有一个自定义屏幕配置 myscreenconfig 和一个 .screenrcmyscreenconfig 看起来像这样:

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

.screenrc 在顶部有这些行:

altscreen on
shell -${SHELL}

我的 .bash_profile 文件设置了很多东西,然后调用 源$HOME/.bash_aliases

如果我在没有任何参数的情况下启动 screen,我的 .bash_profile 会被加载,并且 .bash_aliases 也会被加载。但是,如果我通过 screen -c myscreenconfig 启动 screen,则仅加载 .bash_profile,而不加载 .bash_aliases。为什么?我该如何解决这个问题?

I have a custom screen configuration myscreenconfig and a .screenrc. myscreenconfig looks like this:

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

.screenrc has these lines at the top:

altscreen on
shell -${SHELL}

My .bash_profile file sets a lot of things and then calls source $HOME/.bash_aliases.

If I start screen without any arguments, my .bash_profile gets loaded and .bash_aliases gets loaded. But if I start screen via screen -c myscreenconfig, only .bash_profile gets loaded, and not .bash_aliases. Why? How can I fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

情栀口红 2024-10-17 14:34:36

对我有用的是在我有 bash 设置的地方和 .bashrc (我没有)之间建立一个符号链接:

ln -s ~/.bash_profile ~/.bashrc

What worked for me was making a symbolic link between wherever I had my bash settings and .bashrc (which I did not have):

ln -s ~/.bash_profile ~/.bashrc
╰つ倒转 2024-10-17 14:34:36

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

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

在删除 if< 之前的注释符号 (#) 后/code> 块行,.bashrc 中的设置也可以在屏幕会话中使用。

I had the same problem on one of the machines I use. After reading the suggestion above about linking the two bash resource files, I realized that the following section had been put in comment in the .bash_profile file on this particular machine:

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

After removing the comment signs (#) from before the if block lines, settings in .bashrc became available in screen sessions as well.

满地尘埃落定 2024-10-17 14:34:36

因为您没有在 myscreenconfig 中使用登录 shell。使用 (IIRC) screen 0 -bash,或尝试与 deflogin on 组合。

Because you are not using login shells in myscreenconfig. Use (IIRC) screen 0 -bash, or try combinations with deflogin on.

宣告ˉ结束 2024-10-17 14:34:36

我在我的 .bashrc 中使用它

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

I'm use this in my .bashrc

if [ "$TERM" = "screen" ]; then
        if [ -f ~/.bash_profile ]; then
                . ~/.bash_profile
        fi
fi
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文