Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Two prompts automatically with 4 lines of code
Hello,
following code in ~/.zshrc:
# Load when in ~/tmp
zplugin ice load'![[ $PWD = */tmp* ]]' unload'![[ $PWD != */tmp* ]]' atload"promptinit; prompt sprint3"
zplugin load psprint/zprompts
# Load when NOT in ~/tmp
zplugin ice load'![[ $PWD != */tmp* ]]' unload'![[ $PWD = */tmp* ]]'
zplugin load russjohnson/angry-fly-zsh
Switches between 2 prompt-theme plugins, depending on current working directory. It looks like this: https://asciinema.org/a/150825
Zplugin has this enviroment-tracking, or Zsh-state-tracking, when it loads a plugin, and it implements *unload* this way, by reversing changes. This is a delicate thing and can be long further worked on (waiting for feedback). I've had hard thoughts on this feature, "who ever unloads any plugin?", "who unloads syntax-highlighting?", but now the moral is that accumulating a technology even when no current use case exists can make sense. The switching on condition is possible thanks to sched-patch (included in 5.3) that made sched not miss any event.
--
Sebastian Gniazdowski
psprint /at/ zdharma.org
Messages sorted by:
Reverse Date,
Date,
Thread,
Author