From: Joerg Jaspert Date: Sun, 7 Apr 2013 13:29:39 +0000 (+0200) Subject: new way of handling plugins, allow oh-my-zsh plugins too X-Git-Tag: 0.0.42^0 X-Git-Url: https://git.ganneff.de//index.cgi?p=zsh.git;a=commitdiff_plain;h=1692aee1f323c330bcadbbdfb08e40362aa37e16 new way of handling plugins, allow oh-my-zsh plugins too Plugins now defined per zstyle, only those listed there are loaded (or a default set if style isnt defined). and there is a ohmyplugins style now, to allow oh-my-zsh plugins to be loaded, see README for what to do for this. --- diff --git a/.zsh/README.org b/.zsh/README.org index ebf707e..3c95b86 100644 --- a/.zsh/README.org +++ b/.zsh/README.org @@ -204,6 +204,26 @@ jj_update_dinstall () { #+END_SRC +** Plugins +This framework by default has most of its function included directly, +configurable using the zstyle way described already. But there are as +many different needs to a shell as there are users of it, so besides +all the other flexibility already given, one can easily include +"plugins" from wherever. + +Plugins are simply files that contain zsh code. Which can do whatever +it wants with your shell, so be careful. One exception: Unless the +zstyle /:ganneff:config:pluginbindkeys/ is true, plugins are forbidden to +bind keys. + +Two ways to do it: +1. Place the plugin you want to load into =${ZDOTDIR}/plugins= or any + subdirectory of it, and add the full path and filename, relative to + =${ZDOTDIR}/plugins= to the zstyle /ganneff:config:plugins/ in your + =${ZDOTDIR}/zshenv.local=. +2. For oh-my-zsh style plugins, put the plugin directory into a + subdirectory of =${ZDOTDIR}/plugins/ohmy= and add the name to the + zstyle /ganneff:config:ohmyplugins/ in your =${ZDOTDIR}/zshenv.local= * Sources ** Prompt diff --git a/.zsh/zshenv b/.zsh/zshenv index 3878b96..11d3e3c 100644 --- a/.zsh/zshenv +++ b/.zsh/zshenv @@ -25,8 +25,24 @@ DOMAIN=${DOMAIN:-$(hostname -d 2>&-)} DEBUG=${DEBUG:-no} +# In case the user wants oh-my-zsh plugins, we add their path to the +# fpath, as they often have completion functions. +typeset -a ompath +if [[ -d ${ZDOTDIR}/plugins/ohmy ]]; then + local -a omplug + zstyle -a ':ganneff:config' ohmyplugins omplug + for plug in ${omplug}; do + if [[ -f ${ZDOTDIR}/plugins/ohmy/${plug}/${plug}.plugin.zsh ]]; then + ompath+=(${ZDOTDIR}/plugins/ohmy/${plug}) + fi + done +fi +unset omplug + # Path to search for autoloadable functions. -fpath=( ${ZDOTDIR}/functions "$fpath[@]" ) +fpath=( ${ZDOTDIR}/functions $ompath[@] $fpath[@] ) +unset ompath + # Only unique entries please. typeset -U fpath fpath=( ${^fpath}(N-/) ) diff --git a/.zsh/zshenv.local.sample b/.zsh/zshenv.local.sample index 4548305..34aa9c8 100644 --- a/.zsh/zshenv.local.sample +++ b/.zsh/zshenv.local.sample @@ -175,6 +175,27 @@ zstyle ':ganneff:config' dirstackhandling dirpersist ## function calls). # zstyle ':ganneff:config' mimesetup false +## List of plugins to load. +## List their full path, relative to ${ZDOTDIR}/plugins here. +## It doesn't matter where you get the plugins from, as long as they are +## zsh files that can be sourced. As they can do everything, be careful +## what you load. +# zstyle ':ganneff:config' plugins git-extras.plugin.zsh \ +# history-substring-search.zsh \ +# per-directory-history.plugin.zsh + +## oh-my-zsh plugins can also be loaded, in case you like one of it. +## Simply list their names here, and put their directories into +## ${ZDOTDIR}/plugins/ohmy +#zstyle ':ganneff:config' ohmyplugins extract + +## Allow plugins to bind keys? I really dislike if plugins overwrite my +## keybindings, so I always do them myself. If you prefer to let them do +## it, set it to true. If set to false, you most probably want a +## ${ZDOTDIR}/80_KeyBindings.zsh.local (or one of the variable +## subdirectories, Keybindings.zsh) to set the keybindings. +# zstyle ':ganneff:config' pluginbindkeys false + ######################################################################## ### Prompt setup ### ## use vcs_info in prompt