apply "PATCH: vcs_info, implement disable-patterns style (2nd try)" from ft
[grml-etc-core.git] / etc / zsh / zshrc
index cf15db6..258ee0e 100644 (file)
 ################################################################################
 
 # zsh-refcard-tag documentation: {{{
-#   You may notice strange looking comments in the zshrc (and ~/.zshrc as
-#   well). These are there for a purpose. grml's zsh-refcard can now be
+#   You may notice strange looking comments in this file.
+#   These are there for a purpose. grml's zsh-refcard can now be
 #   automatically generated from the contents of the actual configuration
-#   files. However, we need a little extra information on which comments
+#   file. However, we need a little extra information on which comments
 #   and what lines of code to take into account (and for what purpose).
 #
 # Here is what they mean:
@@ -102,6 +102,40 @@ NOPRECMD=${NOPRECMD:-0}
 BATTERY=${BATTERY:-0}
 GRMLSMALL_SPECIFIC=${GRMLSMALL_SPECIFIC:-1}
 GRML_ALWAYS_LOAD_ALL=${GRML_ALWAYS_LOAD_ALL:-0}
+GRML_WARN_SKEL=${GRML_WARN_SKEL:-1}
+
+if (( GRML_WARN_SKEL != 0 )) ; then
+    printf '
+Dear user,
+
+You updated grml'\''s zshrc which brings a major change.
+The configuration is kept only in one file, being the global zshrc.
+In the past, the configuration was split in two files, with the
+second file being the .zshrc file from /etc/skel.
+
+If you have a .zshrc file in your home directory that originally
+came from the skel directory, please remove it. This is also the case
+if you followed earlier instructions from the grml-zsh-refcard or
+from <http://grml.org/console> on non-grml systems.
+
+Please see the current grml-zsh-refcard for updated installation
+information. In short, you don'\''t want a .zshrc.global file. Install
+the global zshrc to ~/.zshrc and be done.
+
+If you need changes to the configuration, use ~/.zshrc.pre and
+~/.zshrc.local.
+
+To remove this warning execute '\''grml_do_not_warn_skel'\''.
+
+' | more
+
+function grml_do_not_warn_skel() {
+    printf '# Do not warn about old skel dot-files anymore\n' >>! ~/.zshrc.pre
+    printf 'GRML_WARN_SKEL=0\n' >>! ~/.zshrc.pre
+}
+
+fi
+
 # }}}
 
 # {{{ check for version/system
@@ -152,6 +186,11 @@ else
     isgrmlsmall() { return 1 }
 fi
 
+isdarwin(){
+    [[ $OSTYPE == darwin* ]] && return 0
+    return 1
+}
+
 #f1# are we running within an utf environment?
 isutfenv() {
     case "$LANG $CHARSET $LANGUAGE" in
@@ -427,6 +466,18 @@ export SHELL='/bin/zsh'
 
 # color setup for ls:
 check_com -c dircolors && eval $(dircolors -b)
+# color setup for ls on OS X:
+isdarwin && export CLICOLOR=1
+
+# do MacPorts setup on darwin
+if isdarwin && [[ -d /opt/local ]]; then
+    # Note: PATH gets set in /etc/zprofile on Darwin, so this can't go into
+    # zshenv.
+    PATH="/opt/local/bin:/opt/local/sbin:$PATH"
+    MANPATH="/opt/local/share/man:$MANPATH"
+fi
+# do Fink setup on darwin
+isdarwin && xsource /sw/bin/init.sh
 
 # set width of man pages to 80 for more convenient reading
 # export MANWIDTH=${MANWIDTH:-80}
@@ -1213,6 +1264,11 @@ zstyle ':vcs_info:*' max-exports 1
 #   disable             - Provide a list of systems, you don't want
 #                         the vcs_info() to check for repositories
 #                         (checked in the 'init' context, too).
+#   disable-patterns    - A list of patterns that are checked against $PWD.
+#                         If the pattern matches, vcs_info will be disabled.
+#                         Say, ~/.zsh is a directory under version control,
+#                         in which you do not want vcs_info to be active, do:
+#                         zstyle ':vcs_info:*' disable-patterns "$HOME/.zsh+(|/*)"
 #   use-simple          - If there are two different ways of gathering
 #                         information, you can select the simpler one
 #                         by setting this style to true; the default
@@ -1233,6 +1289,7 @@ zstyle ':vcs_info:*' max-exports 1
 #   max-exports         2
 #   enable              true
 #   disable             (empty list)
+#   disable-patterns    (empty list)
 #   use-simple          false
 #   use-prompt-escapes  true
 #
@@ -1797,8 +1854,9 @@ vcs_info_lastmsg () { # {{{
 }
 # }}}
 vcs_info () { # {{{
+    local pat
     local -i found
-    local -a VCSs disabled
+    local -a VCSs disabled dps
     local -x vcs usercontext
     local -ax msgs
     local -Ax vcs_comm
@@ -1831,6 +1889,15 @@ vcs_info () { # {{{
         return 0
     }
     zstyle -a ":vcs_info:${vcs}:${usercontext}" "disable" disabled
+
+    zstyle -a ":vcs_info:${vcs}:${usercontext}:${rrn}" "disable-patterns" dps
+    for pat in ${dps} ; do
+        if [[ ${PWD} == ${~pat} ]] ; then
+            [[ -n ${vcs_info_msg_0_} ]] && VCS_INFO_set --clear
+            return 0
+        fi
+    done
+
     VCS_INFO_maxexports
 
     (( found = 0 ))
@@ -2112,25 +2179,29 @@ zsh-help - hints for use of zsh on grml
 =======================================$reset_color"
 
     print '
-Main configuration of zsh happens in /etc/zsh/zshrc (global)
-and /etc/skel/.zshrc which is copied to $HOME/.zshrc once.
-The files are part of the package grml-etc-core, if you want to
+Main configuration of zsh happens in /etc/zsh/zshrc.
+That file is part of the package grml-etc-core, if you want to
 use them on a non-grml-system just get the tar.gz from
-http://deb.grml.org/ or get the files from the mercurial
-repository:
+http://deb.grml.org/ or (preferably) get it from the git repository:
+
+  http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc
+
+This version of grml'\''s zsh setup does not use skel/.zshrc anymore.
+The file is still there, but it is empty for backwards compatibility.
+
+For your own changes use these two files:
+    $HOME/.zshrc.pre
+    $HOME/.zshrc.local
 
-  http://git.grml.org/?p=grml-etc-core.git;a=blob_plain;f=etc/zsh/zshrc
-  http://git.grml.org/?p=grml-etc-core.git;a=blob_plain;f=etc/skel/.zshrc
+The former is sourced very early in our zshrc, the latter is sourced
+very lately.
 
-If you want to stay in sync with zsh configuration of grml
-run '\''ln -sf /etc/skel/.zshrc $HOME/.zshrc'\'' and configure
-your own stuff in $HOME/.zshrc.local. System wide configuration
-without touching configuration files of grml can take place
-in /etc/zsh/zshrc.local.
+System wide configuration without touching configuration files of grml
+can take place in /etc/zsh/zshrc.local.
 
-If you want to use the configuration of user grml also when
-running as user root just run '\''zshskel'\'' which will source
-the file /etc/skel/.zshrc.
+Normally, the root user (EUID == 0) does not get the whole grml setup.
+If you want to force the whole setup for that user, too, set
+GRML_ALWAYS_LOAD_ALL=1 in .zshrc.pre in root'\''s home directory.
 
 For information regarding zsh start at http://grml.org/zsh/
 
@@ -2155,7 +2226,7 @@ the zsh yet. :)
 
 A value greater than 0 is enables a feature; a value equal to zero
 disables it. If you like one or the other of these settings, you can
-add them to ~/.zshenv to ensure they are set when sourcing grml'\''s
+add them to ~/.zshrc.pre to ensure they are set when sourcing grml'\''s
 zshrc.'
 
     print "
@@ -2217,8 +2288,6 @@ if [[ -r /etc/debian_version ]] ; then
     alias llog="$PAGER /var/log/syslog"     # take a look at the syslog
     #a1# Take a look at the syslog: \kbd{tail -f /var/log/syslog}
     alias tlog="tail -f /var/log/syslog"    # follow the syslog
-    #a1# (Re)-source \kbd{/etc/skel/.zshrc}
-    alias zshskel="source /etc/skel/.zshrc" # source skeleton zshrc
 fi
 
 # sort installed Debian-packages by size
@@ -2918,7 +2987,6 @@ for color in BLUE RED GREEN CYAN YELLOW MAGENTA WHITE ; unset $color
 
 # source another config file if present {{{
 xsource "/etc/zsh/zshrc.local"
-xsource "${HOME}/.zshenv"
 # }}}
 
 # "persistent history" {{{
@@ -2928,11 +2996,6 @@ if [[ -r ~/.important_commands ]] ; then
 fi
 # }}}
 
-## genrefcard.pl settings {{{
-### example: split functions-search 8,16,24,32
-#@# split functions-search 8
-## }}}
-
 #:grep:marker:for:mika: :-)
 ### non-root (EUID != 0) code below
 ###
@@ -4266,9 +4329,15 @@ xsource "${HOME}/.zshrc.local"
 
 # }}}
 
-### doc strings for external functions from files {{{
+## genrefcard.pl settings {{{
+
+### doc strings for external functions from files
 #m# f5 grml-wallpaper() Sets a wallpaper (try completion for possible values)
-#}}}
+
+### example: split functions-search 8,16,24,32
+#@# split functions-search 8
+
+## }}}
 
 ## END OF FILE #################################################################
 # vim:filetype=zsh foldmethod=marker autoindent expandtab shiftwidth=4