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
2 changed files with 5 additions and 7 deletions
|
@ -31,9 +31,11 @@ git clone "https://github.com/xylous/gitstatus.zsh.git" gitstatus
|
|||
Add the following lines to your zshrc:
|
||||
|
||||
```zsh
|
||||
source path/to/installation/gitstatus.plugin.zsh
|
||||
|
||||
function precmd()
|
||||
{
|
||||
local gitstatus="$(path/to/installation/gitstatus.plugin.zsh)"
|
||||
local gitstatus="$(gitstatus)"
|
||||
PS1="%F{blue}%~%F{default} ${gitstatus} $ "
|
||||
}
|
||||
```
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#!/usr/bin/zsh
|
||||
|
||||
function main()
|
||||
function gitstatus()
|
||||
{
|
||||
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
|
||||
case "$status_line" in
|
||||
' M '*)
|
||||
' M '*)
|
||||
((modified++))
|
||||
;;
|
||||
'A '*|'M '*)
|
||||
|
@ -149,5 +147,3 @@ function git_determine_color()
|
|||
typeset -g REPLY="$yellow"
|
||||
return 0
|
||||
}
|
||||
|
||||
main
|
||||
|
|
Loading…
Reference in a new issue