【问题标题】:Why is my .bash_profile breaking when a new "screen" session is made? [closed]为什么创建新的“屏幕”会话时我的 .bash_profile 会中断? [关闭]
【发布时间】:2020-06-26 19:42:24
【问题描述】:

文件~/.bash_profile (.bash_profile)

每当我在我的 Mac 上创建一个新的 screen 会话时,都会显示终端窗口

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

为什么函数git_colorgit_branch 没有在screen 会话上执行?

有没有办法实现它?

【问题讨论】:

  • 对于未来,有关配置和使用交互式 shell 环境的问题更适合我们的姊妹站点Unix & Linux

标签: bash macos unix terminal


【解决方案1】:

我不完全确定 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

【讨论】:

  • 替代移动 git_colorgit_branch.bash_profile.bashrc
猜你喜欢
  • 1970-01-01
  • 2012-01-19
  • 1970-01-01
  • 1970-01-01
  • 2012-05-22
  • 2020-04-25
  • 1970-01-01
  • 2010-12-03
  • 1970-01-01
相关资源
最近更新 更多