mirror of
https://github.com/jimeh/git-aware-prompt.git
synced 2026-02-19 05:36:38 +00:00
Update readme with additions of suggested prompt configs and more
This commit is contained in:
55
README.md
55
README.md
@@ -6,9 +6,8 @@ run `git status` to see which branch you're currently on.
|
||||
|
||||
The solution to this is to have your terminal prompt display the current
|
||||
branch. There's a [number][1] [of][2] [articles][3] [available][4] online
|
||||
about how to achieve this.
|
||||
|
||||
I based this project mainly on Aaron Crane's [solution][1].
|
||||
about how to achieve this. This project is an attempt to make an easy to
|
||||
install/configure solution.
|
||||
|
||||
[1]: http://aaroncrane.co.uk/2009/03/git_branch_prompt/
|
||||
[2]: http://railstips.org/2009/2/2/bedazzle-your-bash-prompt-with-git-info
|
||||
@@ -35,11 +34,37 @@ cd ~/.bash
|
||||
git clone git://github.com/jimeh/git-aware-prompt.git
|
||||
```
|
||||
|
||||
Edit your `~/.profile` or `~/.bash_profile` and add the following to the top:
|
||||
Edit your `~/.bash_profile` or `~/.profile` and add the following to the top:
|
||||
|
||||
```bash
|
||||
export GITAWAREPROMPT=~/.bash/git-aware-prompt
|
||||
source $GITAWAREPROMPT/main.sh
|
||||
```
|
||||
|
||||
|
||||
## Configuring
|
||||
|
||||
Once installed, there will be new `$git_branch` and `$git_dirty` variables
|
||||
available to use in the `PS1` environment variable, along with a number of
|
||||
color helper variables which you can see a list of in [colors.sh][].
|
||||
|
||||
[colors.sh]: https://github.com/jimeh/git-aware-prompt/blob/master/colors.sh
|
||||
|
||||
If you want to know more about how to customize your prompt, I recommend
|
||||
this article: [How to: Change / Setup bash custom prompt (PS1)][how-to]
|
||||
|
||||
[how-to]: http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
|
||||
|
||||
|
||||
### Suggested Prompts
|
||||
|
||||
Below are a few suggested prompt configurations. Simply paste the code at the
|
||||
end of the same file you pasted the installation code into earlier.
|
||||
|
||||
|
||||
#### Mac OS X
|
||||
|
||||
```bash
|
||||
export PS1="\u@\h \w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "
|
||||
```
|
||||
|
||||
@@ -50,24 +75,20 @@ this line:
|
||||
export SUDO_PS1="\[$bakred\]\u@\h\[$txtrst\] \w\$ "
|
||||
```
|
||||
|
||||
The new prompt will take effect beginning in your next session. This usually
|
||||
means logging out completely. To enable it in your current session, you can
|
||||
simply run `source ~/.profile` or `source ~/.bash_profile` (whichever you
|
||||
edited above) in your terminal.
|
||||
|
||||
#### Ubuntu
|
||||
|
||||
## Configuring
|
||||
Standard:
|
||||
|
||||
If you followed the above installation instructions, you've added the default
|
||||
prompt style already by defining the `PS1` variable. If you don't know how to
|
||||
customize your prompt, I recommend you check [this][5] how-to.
|
||||
```bash
|
||||
export PS1="\${debian_chroot:+(\$debian_chroot)}\u@\h:\w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "
|
||||
```
|
||||
|
||||
[5]: http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
|
||||
Colorized:
|
||||
|
||||
Basically, to have the current Git branch shown, simply add `$git_branch` to
|
||||
your `PS1` variable, and make sure the variable value is defined with double
|
||||
quotes. A set of color variables have also been set for you to use. For a list
|
||||
of available colors check `colors.sh`.
|
||||
```bash
|
||||
export PS1="\${debian_chroot:+(\$debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "
|
||||
```
|
||||
|
||||
|
||||
## Updating
|
||||
|
||||
Reference in New Issue
Block a user