gpt4 book ai didi

bash - 为什么在创建新的 "screen" session 时我的 .bash_profile 会中断?

转载 作者:行者123 更新时间:2023-12-04 10:24:15 24 4
gpt4 key购买 nike

关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。












想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。

去年关闭。




Improve this question




New Terminal Window

New screen session

文件 :~/.bash_profile ( .bash_profile )

每当我创建一个新 screen我的 Mac 上的 session ,终端窗口将显示

bash: git_color: command not found
bash: git_branch: command not found

为什么是函数 git_colorgit_branch没有在 screen 上执行 session ?

有没有其他选择来实现它?

最佳答案

我不完全确定如何screen作品。

似乎是.bash_profile不会作为 screen 执行没有创建登录 shell 。 [1]

按照一般的 bash 规则,PS1正在被 screen 发出的 shell 读取因为你导出了。

即,你这样做了:

export PS1

对你的函数做同样的事情。 [2]

将 2 个命令添加到您的 .bash_profile在定义了两个函数之后:
export -f git_color
export -f git_branch

或者,添加这些函数和 PS1.bashrc以及。

[1] About .bash_profile and .bashrc

[2] Exporting functions

关于bash - 为什么在创建新的 "screen" session 时我的 .bash_profile 会中断?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60693360/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com