Skip to content

Commit 2c78758

Browse files
committed
Improve zsh example
1 parent b6b5ed1 commit 2c78758

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

README.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,17 @@ git-ps1 # will output "master"
3434
git-ps1 " [%s]" # will output " [master]"
3535
```
3636

37-
### zsh
37+
### zsh example
3838

3939
Add the following to your `~/.zshrc` file:
4040

4141
```
42-
setopt promptsubst
43-
local gitps1='$(git-ps1 " [%s]")'
44-
export PROMPT="~%C${gitps1}%# "
42+
setopt PROMPT_SUBST ; PS1='~%C$(git-ps1 " (%s)")%# '
4543
```
4644

47-
Besides the first two linces, the important part in the `export`
48-
statement is `${gitps1}` which you can just add to your existing
49-
`PROMPT` if you have already modified it. The above lines will modify
50-
your prompt to show a tilde `~` followed by the current directory name
51-
(`%C`), followed by `[]` optionally containing the git branch name and
52-
emoji and terminated by `% `.
45+
The above commands will modify your prompt to show a tilde (`~`)
46+
followed by the current directory name (`%C`) followed by the ouput of
47+
`git-ps1` and terminated by `% `.
5348

5449
## License
5550

0 commit comments

Comments
 (0)