Add Emacs local variables at EOF equivalent to vim's.
[grml-etc-core.git] / etc / zsh / zshrc
index b0c7a06..64503c2 100644 (file)
@@ -134,7 +134,12 @@ is43(){
 }
 
 is433(){
-    [[ $ZSH_VERSION == 4.3.<3->* || $ZSH_VERSION == <5->* ]] && return 0
+    [[ $ZSH_VERSION == 4.3.<3->* || $ZSH_VERSION == 4.<4->* || $ZSH_VERSION == <5->* ]] && return 0
+    return 1
+}
+
+is439(){
+    [[ $ZSH_VERSION == 4.3.<9->* || $ZSH_VERSION == 4.<4->* || $ZSH_VERSION == <5->* ]] && return 0
     return 1
 }
 
@@ -276,6 +281,7 @@ setopt nobeep               # avoid "beep"ing
 setopt pushd_ignore_dups    # don't push the same dir twice.
 setopt noglobdots           # * shouldn't match dotfiles. ever.
 setopt noshwordsplit        # use zsh style word splitting
+setopt unset                # don't error out when unset parameters are used
 
 # }}}
 
@@ -617,6 +623,11 @@ zle -N slash-backward-kill-word
 #k# Kill everything in a word up to its last \kbd{/}
 bindkey '\ev' slash-backward-kill-word
 
+# use the new *-pattern-* widgets for incremental history search
+if is439 ; then
+    bindkey '^r' history-incremental-pattern-search-backward
+    bindkey '^s' history-incremental-pattern-search-forward
+fi
 # }}}
 
 # a generic accept-line wrapper {{{
@@ -639,7 +650,7 @@ bindkey '\ev' slash-backward-kill-word
 zstyle ':acceptline:*' rehash true
 
 function Accept-Line() {
-    setopt localoptions noksharrays
+    emulate -L zsh
     local -a subs
     local -xi aldone
     local sub
@@ -658,6 +669,7 @@ function Accept-Line() {
 }
 
 function Accept-Line-getdefault() {
+    emulate -L zsh
     local default_action
 
     zstyle -s ":acceptline:${alcontext}" default_action default_action
@@ -672,7 +684,7 @@ function Accept-Line-getdefault() {
 }
 
 function accept-line() {
-    setopt localoptions noksharrays
+    emulate -L zsh
     local -a cmdline
     local -x alcontext
     local buf com fname format msg default_action
@@ -1840,6 +1852,7 @@ vcs_info_printsys () { # {{{
 }
 # }}}
 vcs_info_lastmsg () { # {{{
+    emulate -L zsh
     local -i i
 
     VCS_INFO_maxexports
@@ -1855,6 +1868,8 @@ vcs_info_lastmsg () { # {{{
 }
 # }}}
 vcs_info () { # {{{
+    emulate -L zsh
+    setopt extendedglob
     local pat
     local -i found
     local -a VCSs disabled dps
@@ -2123,7 +2138,7 @@ alias rm='nocorrect rm'         # no spelling correction on rm
 
 #a1# Execute \kbd{rmdir}
 alias rd='rmdir'
-#a1# Execute \kbd{rmdir}
+#a1# Execute \kbd{mkdir}
 alias md='mkdir'
 
 # see http://www.cl.cam.ac.uk/~mgk25/unicode.html#term for details
@@ -2158,7 +2173,6 @@ swspeak() {
        export PS1="%m%# "
        /usr/sbin/swspeak-setup $@
      else # old version:
-        aumix -w 90 -v 90 -p 90 -m 90
         if ! [[ -r /dev/softsynth ]] ; then
             flite -o play -t "Sorry, software synthesizer not available. Did you boot with swspeak bootoption?"
             return 1
@@ -2325,12 +2339,17 @@ if check_com -c grep-status ; then
 fi
 
 # if cdrecord is a symlink (to wodim) or isn't present at all warn:
-if [[ -L /usr/bin/cdrecord ]] || ! check_com -c cdrecord ; then
-    if check_com -c wodim ; then
-        alias cdrecord="echo 'cdrecord is not provided under its original name by Debian anymore.
+if [[ -L /usr/bin/cdrecord ]] || ! check_com -c cdrecord; then
+    if check_com -c wodim; then
+        cdrecord() {
+            cat <<EOMESS
+cdrecord is not provided under its original name by Debian anymore.
 See #377109 in the BTS of Debian for more details.
 
-Please use the wodim binary instead' ; return 1"
+Please use the wodim binary instead
+EOMESS
+            return 1
+        }
     fi
 fi
 
@@ -2556,8 +2575,12 @@ If you want to use xinit anyway please call \"/usr/bin/xinit\"."
         fi
     }
 
-    if check_com -c 915resolution ; then
-        alias 855resolution='echo -e "Please use 915resolution as resolution modify tool for Intel graphic chipset."; return -1'
+    if check_com -c 915resolution; then
+        855resolution() {
+            echo "Please use 915resolution as resolution modifying tool for Intel \
+graphic chipset."
+            return -1
+        }
     fi
 
     #a1# Output version of running grml
@@ -2569,7 +2592,10 @@ If you want to use xinit anyway please call \"/usr/bin/xinit\"."
     fi
 
     if check_com -c grml-debootstrap ; then
-        alias debian2hd='print "Installing debian to harddisk is possible via using grml-debootstrap." ; return 1'
+        debian2hd() {
+            echo "Installing debian to harddisk is possible by using grml-debootstrap."
+            return 1
+        }
     fi
 }
 # }}}
@@ -2973,6 +2999,41 @@ exit 0;
     return $?
 }
 
+ssl_hashes=( sha512 sha256 sha1 md5 )
+
+for sh in ${ssl_hashes}; do
+    ssl-cert-${sh}() {
+        emulate -L zsh
+        if [[ -z $1 ]] ; then
+            printf 'usage: %s <file>\n' "ssh-cert-${sh}"
+            return 1
+        fi
+        openssl x509 -noout -fingerprint -${sh} -in $1
+    }
+done; unset sh
+
+ssl-cert-fingerprints() {
+    emulate -L zsh
+    local i
+    if [[ -z $1 ]] ; then
+        printf 'usage: ssl-cert-fingerprints <file>\n'
+        return 1
+    fi
+    for i in ${ssl_hashes}
+        do ssl-cert-$i $1;
+    done
+}
+
+ssl-cert-info() {
+    emulate -L zsh
+    if [[ -z $1 ]] ; then
+        printf 'usage: ssl-cert-info <file>\n'
+        return 1
+    fi
+    openssl x509 -noout -text -in $1
+    ssl-cert-fingerprints $1
+}
+
 # }}}
 
 # {{{ make sure our environment is clean regarding colors
@@ -3047,20 +3108,6 @@ alias CO="./configure"
 #a2# Execute \kbd{./configure --help}
 alias CH="./configure --help"
 
-# arch/tla stuff
-if check_com -c tla ; then
-    #a2# Execute \kbd{tla what-changed --diffs | less}
-    alias tdi='tla what-changed --diffs | less'
-    #a2# Execute \kbd{tla-buildpackage}
-    alias tbp='tla-buildpackage'
-    #a2# Execute \kbd{tla archive-mirror}
-    alias tmi='tla archive-mirror'
-    #a2# Execute \kbd{tla commit}
-    alias tco='tla commit'
-    #a2# Execute \kbd{tla star-merge}
-    alias tme='tla star-merge'
-fi
-
 # listing stuff
 #a2# Execute \kbd{ls -lSrah}
 alias dir="ls -lSrah"
@@ -3071,7 +3118,7 @@ alias lsa='ls -a .*(.)'                # only show dot-files
 #a2# Only files with setgid/setuid/sticky flag
 alias lss='ls -l *(s,S,t)'             # only files with setgid/setuid/sticky flag
 #a2# Only show 1st ten symlinks
-alias lsl='ls -l *(@[1,10])'           # only symlinks
+alias lsl='ls -l *(@)'                 # only symlinks
 #a2# Display only executables
 alias lsx='ls -l *(*)'                 # only executables
 #a2# Display world-{readable,writable,executable} files
@@ -3103,8 +3150,6 @@ alias r-x='chmod 755'
 #a2# Execute \kbd{mkdir -o}
 alias md='mkdir -p'
 
-check_com -c ipython && alias ips='ipython -p sh'
-
 # console stuff
 #a2# Execute \kbd{mplayer -vo fbdev}
 alias cmplayer='mplayer -vo fbdev'
@@ -3123,12 +3168,6 @@ check_com -c python && alias http="python -m SimpleHTTPServer"
 # Use 'g' instead of 'git':
 check_com g || alias g='git'
 
-# check whether Debian's package management (dpkg) is running
-if check_com salias ; then
-    #a2# Check whether a dpkg instance is currently running
-    salias check_dpkg_running="dpkg_running"
-fi
-
 # work around non utf8 capable software in utf environment via $LANG and luit
 if check_com isutfenv && check_com luit ; then
     if check_com -c mrxvt ; then
@@ -3298,7 +3337,11 @@ disassemble(){
 }
 #f5# Firefox remote control - open given URL
 fir() {
-    firefox -a firefox -remote "openURL($1)"
+    if [ -e /etc/debian_version ]; then
+        firefox -a iceweasel -remote "openURL($1)" || firefox ${1}&
+    else
+        firefox -a firefox -remote "openURL($1)" || firefox ${1}&
+    fi
 }
 #f5# Create Directoy and \kbd{cd} to it
 mcd() {
@@ -3372,7 +3415,7 @@ limg() {
     if [[ $#images -eq 0 ]] ; then
         print "No image files found"
     else
-        ls "$@" "$images[@]"
+        ls "$images[@]"
     fi
 }
 
@@ -3629,19 +3672,8 @@ ansi-colors() {
     done
 }
 
-# suidfind() { ls -latg $path | grep '^...s' }
 #f5# Find all files in \$PATH with setuid bit set
-suidfind() { ls -latg $path/*(sN) }
-
-# See above but this is /better/ ... anywise ..
-findsuid() {
-    print 'Output will be written to ~/suid_* ...'
-    $SUDO find / -type f \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suidfiles.`date "+%Y-%m-%d"`.out 2>&1
-    $SUDO find / -type d \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suiddirs.`date "+%Y-%m-%d"`.out 2>&1
-    $SUDO find / -type f \( -perm -2 -o -perm -20 \) -ls > ~/suid_writefiles.`date "+%Y-%m-%d"`.out 2>&1
-    $SUDO find / -type d \( -perm -2 -o -perm -20 \) -ls > ~/suid_writedirs.`date "+%Y-%m-%d"`.out 2>&1
-    print 'Finished'
-}
+suidfind() { ls -latg $path | grep '^...s' }
 
 # TODO: So, this is the third incarnation of this function!?
 #f5# Reload given functions
@@ -4371,15 +4403,11 @@ if (( GRMLSMALL_SPECIFIC > 0 )) && isgrmlsmall ; then
     unset abk[V]
     unalias    'V'      &> /dev/null
     unfunction vman     &> /dev/null
-    unfunction vimpm    &> /dev/null
-    unfunction vimhelp  &> /dev/null
     unfunction viless   &> /dev/null
     unfunction 2html    &> /dev/null
 
     # manpages are not in grmlsmall
     unfunction manzsh   &> /dev/null
-    unalias    man2     &> /dev/null
-    unalias    man      &> /dev/null
     unfunction man2     &> /dev/null
 
 fi
@@ -4400,3 +4428,6 @@ zrclocal
 
 ## END OF FILE #################################################################
 # vim:filetype=zsh foldmethod=marker autoindent expandtab shiftwidth=4
+# Local variables:
+# mode: sh
+# End: