sheldon
sheldon copied to clipboard
Conditional sourcing
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.
Quick thought: It can also be used to conditionally load plugins for bash and zsh on different machines.
This would be really useful when you try to load plugins specific to OSTYPE
I'd really appreciate this feature :)
Resolved in #143