# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
# Bug-Reports: see http://grml.org/bugs/
# License: This file is licensed under the GPL v2.
-# Latest change: Mit Aug 08 21:22:03 CEST 2007 [mika]
+# Latest Change: Sat Jan 26 11:55:04 CET 2008
################################################################################
# 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:
-xsource "${HOME}/.zshrc.global"
+
+# 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 '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 ' <http://grml.org/zsh/grml-zsh-refcard.pdf>' >&2
fi
# }}}
# 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 }
# }}}
check_com -c w3m && export BROWSER=w3m
fi
fi
-#v#
-(( ${+PAGER} )) || export PAGER="less"
#m# v QTDIR \kbd{/usr/share/qt[34]}\quad [for non-root only]
[[ -d /usr/share/qt3 ]] && export QTDIR=/usr/share/qt3
#f4# Search for newspostings from authors
agoogle() { ${=BROWSER} "http://groups.google.com/groups?as_uauthors=$*" ; }
#f4# Search Debian Bug Tracking System by BugID in mbox format
-debbug() { ${=BROWSER} "http://bugs.debian.org/$*" }
+debbug() {
+ setopt localoptions extendedglob
+ if [[ $# -eq 1 ]]; then
+ case "$1" in
+ ([0-9]##)
+ ${=BROWSER} "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=$1"
+ ;;
+ (*@*)
+ ${=BROWSER} "http://bugs.debian.org/cgi-bin/pkgreport.cgi?submitter=$1"
+ ;;
+ (*)
+ ${=BROWSER} "http://bugs.debian.org/$*"
+ ;;
+ esac
+ else
+ print "$0 needs one argument"
+ return 1
+ fi
+}
#f4# Search Debian Bug Tracking System
debbugm() { bts show --mbox $1 } # provide bugnummer as "$1"
#f4# Search DMOZ
fi
}
-# TODO: isn't ssl() like this, but clean?
-# I'd like to remove this, it's a gross hack, IMHO -ft
-#f5# Follow symlinks
-folsym() {
- if [[ -e $1 || -h $1 ]] ; then
- file=$1
- else
- file=`which $1`
- fi
- if [[ -e $file || -L $file ]] ; then
- if [[ -L $file ]] ; then
- echo `ls -ld $file | perl -ane 'print $F[7]'` '->'
- folsym `perl -le '$file = $ARGV[0];
- $dest = readlink $file;
- if ($dest !~ m{^/}) {
- $file =~ s{(/?)[^/]*$}{$1$dest};
- } else {
- $file = $dest;
- }
- $file =~ s{/{2,}}{/}g;
- while ($file =~ s{[^/]+/\.\./}{}) {
- ;
- }
- $file =~ s{^(/\.\.)+}{};
- print $file' $file`
- else
- ls -d $file
- fi
- else
- echo $file
- fi
-}
-
# It's shameless stolen from <http://www.vim.org/tips/tip.php?tip_id=167>
#f5# Use \kbd{vim} as your manpage reader
vman() { man $* | col -b | view -c 'set ft=man nomod nolist' - }
| sed 's/value=//;s/"//g'
}
+#f2# Find history events by search pattern and list them by date.
+whatwhen() {
+# {{{
+ local usage help ident format_l format_s first_char remain first last
+ usage='USAGE: whatwhen [options] <searchstring> <search range>'
+ help='Use' \`'whatwhen -h'\'' for further explanations.'
+ ident=${(l,${#${:-Usage: }},, ,)}
+ format_l="${ident}%s\t\t\t%s\n"
+ format_s="${format_l//(\\t)##/\\t}"
+ # Make the first char of the word to search for case
+ # insensitive; e.g. [aA]
+ first_char=[${(L)1[1]}${(U)1[1]}]
+ remain=${1[2,-1]}
+ # Default search range is `-100'.
+ first=${2:-\-100}
+ # Optional, just used for `<first> <last>' given.
+ last=$3
+ case $1 in
+ ("")
+ printf '%s\n\n' 'ERROR: No search string specified. Aborting.'
+ printf '%s\n%s\n\n' ${usage} ${help} && return 1
+ ;;
+ (-h)
+ printf '%s\n\n' ${usage}
+ print 'OPTIONS:'
+ printf $format_l '-h' 'show help text'
+ print '\f'
+ print 'SEARCH RANGE:'
+ printf $format_l "'0'" 'the whole history,'
+ printf $format_l '-<n>' 'offset to the current history number; (default: -100)'
+ printf $format_s '<[-]first> [<last>]' 'just searching within a give range'
+ printf '\n%s\n' 'EXAMPLES:'
+ printf ${format_l/(\\t)/} 'whatwhen grml' '# Range is set to -100 by default.'
+ printf $format_l 'whatwhen zsh -250'
+ printf $format_l 'whatwhen foo 1 99'
+ ;;
+ (\?)
+ printf '%s\n%s\n\n' ${usage} ${help} && return 1
+ ;;
+ (*)
+ # -l list results on stout rather than invoking $EDITOR.
+ # -i Print dates as in YYYY-MM-DD.
+ # -m Search for a - quoted - pattern within the history.
+ fc -li -m "*${first_char}${remain}*" $first $last
+ ;;
+ esac
+# }}}
+}
+
# change fluxbox keys from 'Alt-#' to 'Alt-F#' and vice versa
fluxkey-change() {
[[ -n "$FLUXKEYS" ]] || local FLUXKEYS="$HOME/.fluxbox/keys"
weather() {
[[ -n "$1" ]] || {
print 'Usage: weather <station_id>' >&2
+ print 'List of stations: http://en.wikipedia.org/wiki/List_of_airports_by_ICAO_code'>&2
return 1
}
return 1
fi
}
-
-
# }}}
# mercurial related stuff {{{
### doc strings for external functions from files
#m# f5 grml-wallpaper() Sets a wallpaper (try completion for possible values)
## END OF FILE #################################################################
-# vim:foldmethod=marker
+# vim:foldmethod=marker autoindent expandtab shiftwidth=4