切换导航
新动弹计划
搜索
文章
动弹
排行榜
登录
注册
×
搜索
文章
动弹
热门关键词
重读《掌控习惯》
ChatGPT
Docker
Laravel
读书
跑步
#daily tips#
#稍后阅读#
Falcon
2022-10-22 07:44
冒泡
#daily tips#
解决screen命令下错误:
bash: parse_git_branch: command not found
原因是:parse_git_branch被定义在~/.bash_profile,或是/etc/profile(在n1下),screen实际上是启动了一个non-login shell,它不会读取 ~/.bash_profile 。但/etc/profiles 比较特殊,根据发行版不同,在non-login shell启动时可能读取也可能不读取,在n1的openwrt是不读取的。但会读取~/.bashrc,因此可以把 parse_git_branch函数的定义放在这里。
判断你是否处于login shell还是non-login shell的方式:
1. 在终端输入 echo $0 ,如果返回的结果以 “-”开头,说明你是处理login shell,否则属于non-login shell,如screen下输出的是/bin/bash。
2. 如果是在bash下,还可以通过运行命令 shopt login_shell 直观地检查当前的是否为 login_shell 。
参考资料:
- 关于login shell和non login shell的区别:
https://unix.stackexchange.com/questions/38175/difference-between-login-shell-and-non-login-shell
- bash: parse_git_branch: command not found:
https://stackoverflow.com/questions/35881412/bash-parse-git-branch-command-not-found
0
暂无评论