rossmacarthur / sheldon

:bowtie: Fast, configurable, shell plugin manager
https://sheldon.cli.rs
Apache License 2.0
960 stars 21 forks source link

Conditional sourcing #119

Closed denysdovhan closed 1 year ago

denysdovhan commented 2 years ago

I'd love to some kind of when option in the config file, for conditional sourcing. For example, I had this configuration with zplug

if [[ -d "$HOME/Projects/Repos/spaceship/spaceship-prompt" ]]; then
  zplug "$HOME/Projects/Repos/spaceship/spaceship-prompt", from:local, as:theme, use:"spaceship.zsh"
else
  zplug "denysdovhan/spaceship-prompt", as:theme, use:"spaceship.zsh"
fi

I guess it's possible to make something like this in sheldon:

[plugins.spaceship]
github = 'spaceship-prompt/spaceship-prompt'
when = 'test ! -d "$HOME/Projects/Repos/spaceship/spaceship-prompt"'

[plugins.spaceship-local]
local = '$HOME/Projects/Repos/spaceship/spaceship-prompt'
when = 'test ! -d "$HOME/Projects/Repos/spaceship/spaceship-prompt"'

In the example above, when option will execute the command. Entry will be sourced if it was executed with zero exit code. Additionally a skip command might be introduced to do the opposite.

denysdovhan commented 2 years ago

Quick thought: It can also be used to conditionally load plugins for bash and zsh on different machines.

TheCodeDestroyer commented 2 years ago

This would be really useful when you try to load plugins specific to OSTYPE

Laura7089 commented 1 year ago

I'd really appreciate this feature :)

rossmacarthur commented 1 year ago

Resolved in #143