Git的完成和PS1不工作:" __ git_ps1:找不到命令"在"须藤-s"或QUOT;须藤苏"在Ubuntu 12.04 [英] Git completion and PS1 not working: "__git_ps1: command not found" on "sudo -s" or "sudo su" on Ubuntu 12.04

查看:326
本文介绍了Git的完成和PS1不工作:" __ git_ps1:找不到命令"在"须藤-s"或QUOT;须藤苏"在Ubuntu 12.04的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装的git和git流完成增加这些线路的.bashrc根和Ubuntu的12.04机器上normal_user:

I installed git and git-flow completion adding these line to .bashrc of root and a normal_user on a Ubuntu 12.04 machine:

source /etc/git-completion.bash
source /etc/git-flow-completion.bash
GIT_PS1_SHOWUPSTREAM="verbose"
GIT_PS1_SHOWDIRTYSTATE=true
PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ '

当我以root身份登录或normal_user混帐完成的作品。但是,如果我用命令-s或须藤苏混帐完成不工作,我不断地得到__git_ps1:命令未找到每次我preSS的回报。
我试图删除源命令,并用的apt-get安装的bash补全(bash的自动完成已安装)。所以,即使没有2源我得到完全相同的行为。

When I log as root or normal_user git completion works. However if I use "sudo -s" or "sudo su" git completion is not working and I continually get "__git_ps1: command not found" each time I press return. I tried to remove the "source" commands and use "apt-get install bash-completion" (bash-completion was already installed). So even without the 2 source I get the exact same behavior.

任何人知道问题是什么,以及如何使它工作?

Anybody knows what the problem is and how to make it work?

推荐答案

当你做须藤苏这将不获取用户的的.bashrc 。该PS1是从用户继承你做了须藤苏从但新的shell不知道在哪里可以找到 ___ git_ps1

When you do sudo su it won't source the users .bashrc. The PS1 is inherited from the user you did the sudo su from but the new shell doesn't know where it can find ___git_ps1

您需要通过执行来模拟一个登录须藤苏-l

You need to simulate a login by executing sudo su -l

这篇关于Git的完成和PS1不工作:" __ git_ps1:找不到命令"在"须藤-s"或QUOT;须藤苏"在Ubuntu 12.04的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆