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:
xylous 2021-08-08 18:34:17 +03:00
parent ebf8726ab7
commit 0387deb641
2 changed files with 5 additions and 7 deletions

View File

@ -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} $ "
} }
``` ```

View File

@ -1,6 +1,4 @@
#!/usr/bin/zsh function gitstatus()
function main()
{ {
is_in_git_repository || return 1 is_in_git_repository || return 1
@ -149,5 +147,3 @@ function git_determine_color()
typeset -g REPLY="$yellow" typeset -g REPLY="$yellow"
return 0 return 0
} }
main