zsh-users
 help / color / mirror / code / Atom feed
* Two prompts automatically with 4 lines of code
@ 2017-12-05 11:00 Sebastian Gniazdowski
  0 siblings, 0 replies; only message in thread
From: Sebastian Gniazdowski @ 2017-12-05 11:00 UTC (permalink / raw)
  To: Zsh Users

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-12-05 11:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-05 11:00 Two prompts automatically with 4 lines of code Sebastian Gniazdowski

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).