-bash:__git_ps1:找不到命令 [英] -bash: __git_ps1: command not found

查看:30
本文介绍了-bash:__git_ps1:找不到命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试安装 Ruby 2.0.我的命令行 urped 现在如下所示:

I tried to install Ruby 2.0. My command line urped and now looks like the following:

-bash: __git_ps1: command not found
[11:58:28][whatever@whatever ~]$ 

我不知道如何摆脱 __git_ps1 command not found 错误.我搜索了我的 .bash_profile 和 .bashrc 以查看它是否正在尝试设置变量或其他内容,但没有看到任何内容.我唯一能找到提到的 git_ps1 的地方是 ~/.dotfiles/.bash_prompt.我完全替换了该文件的内容,注销并重新登录,它没有修复任何问题.

I have not a clue how to get rid of the __git_ps1 command not found error. I've searched my .bash_profile and my .bashrc to see if it's trying to set a variable or something and am not seeing anything. The only place I can find git_ps1 mentioned is in ~/.dotfiles/.bash_prompt. I replace the content of that file completely, logout and log back in and it fixes nothing.

我看到了 ​​这个,但我很陌生命令行,所以我只是把自己弄糊涂了.

I saw this, but I'm pretty new to command line so I just confused myself.

有什么想法吗?

推荐答案

BASH 有很多方法可以自动设置提示符,从而为您提供很好的信息.您可以通过设置 PS1 环境变量来设置提示.例如,如果我设置 PS1="$ " 我的提示将如下所示:

BASH has a whole slew of ways of automatically setting your prompt to give you nice information. You set the prompt by setting the PS1 environment variable. For example, if I set PS1="$ " my prompt will look like this:

$ 

信息量不大.我只能说命令行在提示我.

Not too informative. All I can tell is that the command line is prompting me.

但是,如果我设置 PS1=u@h: w$,我的提示现在将如下所示:

However, If I set PS1=u@h: w$, my prompt will now look like this:

david@vegibank:/usr/bin$ 

这告诉我我是如何登录的(u)、我所在的机器(h)以及我所在的目录(w).如果我使用 git,如果我所在的 git 分支也是我的提示符的一部分,那就太好了.

That tells me how I'm logged in (the u), the machine I'm onto (h), and the directory I'm in (the w). If I use git, it would be nice if the git branch I'm in is also part of my prompt.

这正是您的 .profile、您的 .bashrc 文件、您的 .bash_login 或您的 所发生的事情.bash_profile 脚本.或者,一些系统管理员在 /etc/profile 中做了什么.

This is exactly what is going on with your .profile, your .bashrc file, your .bash_login or your .bash_profile script. Or, what some system admin did in /etc/profile.

您可以做几件事.要么:

There are a couple things you can do. Either:

  • 下载缺少的 __git_ps1 并确保它在您的 $PATH 环境变量中(由上述各种初始化文件的组合设置)
  • 在正在执行的任何初始化文件中更改您的 PS1 环境变量(我相信它可能是 .bash_profile.
  • Download the missing __git_ps1 and make sure it's in your $PATH environment variable (which is set by a combination of the various initialization files mentioned above)
  • Change your PS1 environment variable in whatever initialization file is being executed (I believe it is probably .bash_profile.

只需将其添加为最后一行:

Just add this as the last line:

PS1="u@h:w
$ "

添加的 在下面一行打印美元符号提示,如下所示:

The added prints the dollar sign prompt on the line below like this:

david@vegibank:/usr/bin
$ 

我喜欢这样做,因为提示可能会变得相当长,并且当提示超过 30 到 50 个字符时,编辑命令行会变得很棘手.否则,这几乎是大多数用户使用的标准提示.您可以在 手册页 中查看有关设置 BASH 提示的更多信息.(在该页面上搜索提示"一词).

I like to do that because the prompt can get rather long and editing the command line gets tricky when the prompt is longer than 30 to 50 characters. Otherwise, it's pretty much the standard prompt that most users use. You can see more about setting BASH prompts in the man pages. (Search for the word Prompting on that page).

如果您觉得它有点混乱,请庆幸您没有使用 Kornshell.我使用 Kornshell 并获得与 PS1=u@h:w $ 相同的提示,我将提示设置为:

If you find it a bit confusing, be glad you're not using Kornshell. I use Kornshell and to get the same prompt PS1=u@h:w $ does, I set my prompt as:

export PS1='$(print -n "`logname`@`hostname`:";if [[ "${PWD#$HOME}" != "$PWD" ]] then; print -n "~${PWD#$HOME}"; else; print -n "$PWD";fi;print "
$ ")'

这篇关于-bash:__git_ps1:找不到命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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