X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=etc%2Fzsh%2Fzshrc;h=dbcfbf02e414096642f95b02edf93a0ba1e38c13;hb=58ab47020ffa239076ab734f62edfe6ca6379d83;hp=5d3d36f9cab957a171fb4a11d97ee8a6eb18db66;hpb=753a93ad3c5168fad1f596bbabfe9638781db51b;p=grml-etc-core.git diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 5d3d36f..dbcfbf0 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,6 +92,10 @@ 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} @@ -2108,25 +2112,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 - 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 +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 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. +For your own changes use these two files: + $HOME/.zshrc.pre + $HOME/.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. +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 +2159,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 +2221,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 +2847,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 {{{ @@ -2872,8 +2935,8 @@ fi #@# split functions-search 8 ## }}} -### -### 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