Export a function instead of running w/shebang
To make integrating with plugin managers as easy as possible, plugins/scripts shouldn't be sourced on their own; instead, they should export functions.
This commit is contained in:
parent
ebf8726ab7
commit
0387deb641
|
@ -31,9 +31,11 @@ git clone "https://github.com/xylous/gitstatus.zsh.git" gitstatus
|
||||||
Add the following lines to your zshrc:
|
Add the following lines to your zshrc:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
|
source path/to/installation/gitstatus.plugin.zsh
|
||||||
|
|
||||||
function precmd()
|
function precmd()
|
||||||
{
|
{
|
||||||
local gitstatus="$(path/to/installation/gitstatus.plugin.zsh)"
|
local gitstatus="$(gitstatus)"
|
||||||
PS1="%F{blue}%~%F{default} ${gitstatus} $ "
|
PS1="%F{blue}%~%F{default} ${gitstatus} $ "
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#!/usr/bin/zsh
|
function gitstatus()
|
||||||
|
|
||||||
function main()
|
|
||||||
{
|
{
|
||||||
is_in_git_repository || return 1
|
is_in_git_repository || return 1
|
||||||
|
|
||||||
|
@ -84,7 +82,7 @@ function parse_git_status()
|
||||||
{
|
{
|
||||||
git status --porcelain=v1 | while IFS= read -r status_line; do
|
git status --porcelain=v1 | while IFS= read -r status_line; do
|
||||||
case "$status_line" in
|
case "$status_line" in
|
||||||
' M '*)
|
' M '*)
|
||||||
((modified++))
|
((modified++))
|
||||||
;;
|
;;
|
||||||
'A '*|'M '*)
|
'A '*|'M '*)
|
||||||
|
@ -149,5 +147,3 @@ function git_determine_color()
|
||||||
typeset -g REPLY="$yellow"
|
typeset -g REPLY="$yellow"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
|
||||||
|
|
Loading…
Reference in New Issue