Add function example to Tips.git_cmd

This commit is contained in:
Dawid Kurek
2016-01-28 20:21:13 +01:00
parent 0d113a79eb
commit 5915e39afd
4 changed files with 19 additions and 2 deletions

View File

@@ -236,11 +236,11 @@ or don't want to see. All options must be overridden in your **.zshrc** file.
Allows you to specify custom git prompt command. This makes it possible to
change:
![Git_Prompt_Before](./img/tips/git_prompt_before.png)
![Git_Prompt_Origin](./img/tips/git_prompt_origin.png)
into:
![Git_Prompt_After](./img/tips/git_prompt_after.png)
![Git_Prompt_Command](./img/tips/git_prompt_command.png)
with:
@@ -251,6 +251,23 @@ BULLETTRAIN_GIT_PROMPT_CMD=\${\$(git_prompt_info)//\\//\ \ }
Please note we need to delay variable expansion, so we have to escape all
**weird** character - *$*, *\*, *\<space>*, etc.
You can also use function to get more complex commands:
``` bash
BULLETTRAIN_GIT_PROMPT_CMD="\$(custom_git_prompt)"
custom_git_prompt() {
prompt=$(git_prompt_info)
prompt=${prompt//\//\ \ }
prompt=${prompt//_/\ }
echo ${prompt}
}
```
which gives:
![Git_Prompt_Function](./img/tips/git_prompt_function.png)
## Contributors
That project was originally a fork from

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB