X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=etc%2Fzsh%2Fzshrc;h=258ee0ea99880740d911918be255113dc7eb9a05;hb=6cb30e41c45e28f3f55ab554f05301b7bb3eb205;hp=7edb9765fc389737013a87d9e3562f4a81e23661;hpb=b78fe008bd17e50641a9598d263208e3845fdba1;p=grml-etc-core.git diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 7edb976..258ee0e 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -12,10 +12,10 @@ ################################################################################ # 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: @@ -92,12 +92,50 @@ fi # }}} # setting some default values {{{ + +# load .zshrc.pre to give the user the chance to overwrite the defaults +[[ -r ${HOME}/.zshrc.pre ]] && source ${HOME}/.zshrc.pre + NOCOR=${NOCOR:-0} NOMENU=${NOMENU:-0} 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 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 @@ -148,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 @@ -423,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} @@ -1209,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 @@ -1229,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 # @@ -1793,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 @@ -1827,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 )) @@ -2108,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/?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 + http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc -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. +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. -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. +For your own changes use these two files: + $HOME/.zshrc.pre + $HOME/.zshrc.local + +The former is sourced very early in our zshrc, the latter is sourced +very lately. + +System wide configuration without touching configuration files of grml +can take place in /etc/zsh/zshrc.local. + +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/ @@ -2151,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 " @@ -2213,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 @@ -2841,6 +2914,63 @@ bk() { # exec $SHELL $SHELL_ARGS "$@" # } +#f1# grep for patterns in grml's zsh setup +zg() { +#{{{ + LANG=C perl -e ' + +sub usage { + print "usage: zg -[anr] \n"; + print " Search for patterns in grml'\''s zshrc.\n"; + print " zg takes no or exactly one option plus a non empty pattern.\n\n"; + print " options:\n"; + print " -- no options (use if your pattern starts in with a dash.\n"; + print " -a search for the pattern in all code regions\n"; + print " -n search for the pattern in non-root code only\n"; + print " -r search in code for everyone (also root) only\n\n"; + print " The default is -a for non-root users and -r for root.\n\n"; + print " If you installed the zshrc to a non-default locations (ie *NOT*\n"; + print " in /etc/zsh/zshrc) do: export GRML_ZSHRC=\$HOME/.zshrc\n"; + print " ...in case you copied the file to that location.\n\n"; + exit 1; +} + +if ($ENV{GRML_ZSHRC} ne "") { + $RC = $ENV{GRML_ZSHRC}; +} else { + $RC = "/etc/zsh/zshrc"; +} + +usage if ($#ARGV < 0 || $#ARGV > 1); +if ($> == 0) { $mode = "allonly"; } +else { $mode = "all"; } + +$opt = $ARGV[0]; +if ($opt eq "--") { shift; } +elsif ($opt eq "-a") { $mode = "all"; shift; } +elsif ($opt eq "-n") { $mode = "nonroot"; shift; } +elsif ($opt eq "-r" ) { $mode = "allonly"; shift; } +elsif ($opt =~ m/^-/ || $#ARGV > 0) { usage(); } + +$pattern = $ARGV[0]; +usage() if ($pattern eq ""); + +open FH, "<$RC" or die "zg: Could not open $RC: $!\n"; +while ($line = ) { + chomp $line; + if ($line =~ m/^#:grep:marker:for:mika:/) { $markerfound = 1; next; } + next if ($mode eq "nonroot" && markerfound == 0); + break if ($mode eq "allonly" && markerfound == 1); + print $line, "\n" if ($line =~ /$pattern/); +} +close FH; +exit 0; + + ' -- "$@" +#}}} + return $? +} + # }}} # log out? set timeout in seconds {{{ @@ -2857,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" {{{ @@ -2867,61 +2996,18 @@ if [[ -r ~/.important_commands ]] ; then fi # }}} -## genrefcard.pl settings {{{ -### example: split functions-search 8,16,24,32 -#@# split functions-search 8 -## }}} - -# add variable to be able to check whether the file has been read {{{ -ZSHRC_GLOBAL_HAS_BEEN_READ=1 -# }}} - -### -### non-root (EUID == 0) code below +#:grep:marker:for:mika: :-) +### non-root (EUID != 0) code below ### (( GRML_ALWAYS_LOAD_ALL == 0 )) && (( $EUID == 0 )) && return 0 -# source ~/.zshrc.global {{{ - -# see /etc/zsh/zshrc for some general settings -# If you don't have write permissions to /etc/zsh/zshrc on your own -# copy the file to your $HOME as /.zshrc.global and we source it: - -# Note, that xsource() is defined in the global file, so here, -# we will have to do the sourcing manually for once: - -[[ -z "$ZSHRC_GLOBAL_HAS_BEEN_READ" ]] \ -&& [[ -r "${HOME}/.zshrc.global" ]] \ -&& source "${HOME}/.zshrc.global" -# }}} - -# check whether global file has been read {{{ -if [[ -z "$ZSHRC_GLOBAL_HAS_BEEN_READ" ]] ; then - print 'Warning: global zsh config has not been read.' >&2 - print ' prepare for possible errors!' >&2 - print '' >&2 - print 'See our refcard for info on how to get the complete configuration:' >&2 - print ' ' >&2 -fi -# }}} - # autoloading stuff {{{ # associate types and extensions (be aware with perl scripts and anwanted behaviour!) # check_com zsh-mime-setup || { autoload zsh-mime-setup && zsh-mime-setup } # alias -s pl='perl -S' # }}} -# completion system {{{ -# just make sure it is loaded in this file too -# TODO: is this *really* needed? compsys should be run in the global zshrc already. -check_com compinit || { autoload -U compinit && compinit } -# }}} - -# make sure isgrmlsmall is defined {{{ -check_com isgrmlsmall || function isgrmlsmall () { return 1 } -# }}} - # variables {{{ # set terminal property (used e.g. by msgid-chooser) @@ -4243,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