projects
/
grml-etc-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* /etc/skel/.zshrc:
[grml-etc-core.git]
/
etc
/
zsh
/
zshrc
diff --git
a/etc/zsh/zshrc
b/etc/zsh/zshrc
index
6e70e5f
..
ff2fe2c
100644
(file)
--- a/
etc/zsh/zshrc
+++ b/
etc/zsh/zshrc
@@
-3,7
+3,7
@@
# 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.
# 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: Son
Okt 15 23:20:08 CES
T 2006 [mika]
+# Latest change: Son
Nov 19 14:45:18 CE
T 2006 [mika]
################################################################################
# This file is sourced only for interactive shells. It
# should contain commands to set up aliases, functions,
################################################################################
# This file is sourced only for interactive shells. It
# should contain commands to set up aliases, functions,
@@
-14,39
+14,38
@@
# {{{ check for version/system
# check for versions (compatibility reasons)
# {{{ check for version/system
# check for versions (compatibility reasons)
- is4(){
- if [[ $ZSH_VERSION == 4.* ]]; then
- return 0
- else
- return 1
- fi
- }
-
-# current release
- is42(){
- if [[ $ZSH_VERSION == 4.<2->* ]]; then
- return 0
- else
- return 1
- fi
- }
+ if autoload is-at-least && is-at-least 2>/dev/null ; then
+ is4() { is-at-least 4 }
+ is42() { is-at-least 4.2 }
+ else
+ is4(){
+ [[ $ZSH_VERSION == 4.* ]] && return 0
+ return 1
+ }
+ is42(){
+ [[ $ZSH_VERSION == 4.<2->* ]] && return 0
+ return 1
+ }
+ fi
# grml specific stuff
isgrml(){
# grml specific stuff
isgrml(){
- if [ -f /etc/grml_version ] ; then
- return 0
- else
- return 1
- fi
+ [ -f /etc/grml_version ] && return 0
+ return 1
}
isgrmlcd(){
}
isgrmlcd(){
- if [ -f /etc/grml_cd ] ; then
- return 0
- else
- return 1
- fi
+ [ -f /etc/grml_cd ] && return 0
+ return 1
+ }
+
+ if isgrml ; then
+ isgrmlsmall() {
+ [[ ${${${(f)"$(</etc/grml_version)"}%% *}##*-} == 'small' ]] && return 0 ; return 1
}
}
+ else
+ isgrmlsmall() { return 1 }
+ fi
# check for user, if not running as root set $SUDO to sudo
(( EUID != 0 )) && SUDO='sudo' || SUDO=''
# check for user, if not running as root set $SUDO to sudo
(( EUID != 0 )) && SUDO='sudo' || SUDO=''
@@
-63,9
+62,8
@@
# }}}
# {{{ set some variables
# }}}
# {{{ set some variables
- [[ -z "$EDITOR" ]] && export EDITOR='vim'
- [[ -z "$SHELL" ]] && export SHELL='/bin/zsh'
- [[ -z "$MAIL" ]] && export MAIL="/var/mail/$USER"
+ export EDITOR=${EDITOR:-vim}
+ export MAIL=${MAIL:-/var/mail/$USER}
[[ -f ~/.terminfo/m/mostlike ]] && MYLESS='LESS=C TERMINFO=~/.terminfo TERM=mostlike less' || MYLESS='less'
[[ -x /usr/bin/dircolors ]] && eval `dircolors -b`
[[ -f ~/.terminfo/m/mostlike ]] && MYLESS='LESS=C TERMINFO=~/.terminfo TERM=mostlike less' || MYLESS='less'
[[ -x /usr/bin/dircolors ]] && eval `dircolors -b`
@@
-73,7
+71,7
@@
# cdpath=(.. ~)
# Support our own site-functions
# cdpath=(.. ~)
# Support our own site-functions
- [ -d /etc/zsh/site-functions ] &&
export
FPATH=/etc/zsh/site-functions:$FPATH
+ [ -d /etc/zsh/site-functions ] && FPATH=/etc/zsh/site-functions:$FPATH
# automatically remove duplicates from these arrays
typeset -U path cdpath fpath manpath
# automatically remove duplicates from these arrays
typeset -U path cdpath fpath manpath
@@
-132,8
+130,9
@@
fi
# we don't want to quote/espace URLs on our own...
# avoid 'url-quote-magic: function definition file not found' on some older boxes
# we don't want to quote/espace URLs on our own...
# avoid 'url-quote-magic: function definition file not found' on some older boxes
- if [ -f "/usr/share/zsh/$ZSH_VERSION/functions/Zle/url-quote-magic" ] ; then
- autoload -U url-quote-magic && zle -N self-insert url-quote-magic
+ if [ -f "/usr/share/zsh/$ZSH_VERSION/functions/Zle/url-quote-magic" ] && \
+ autoload -U url-quote-magic && zle -N self-insert url-quote-magic ; then
+ zle -N self-insert url-quote-magic
else
print 'Notice: no url-quote-magic available :('
fi
else
print 'Notice: no url-quote-magic available :('
fi
@@
-142,7
+141,7
@@
fi
autoload run-help # use via 'esc-h'
# completion system
autoload run-help # use via 'esc-h'
# completion system
- i
s42 && if autoload -U compinit && [ -f "/usr/share/zsh/$ZSH_VERSION/functions/Completion/compinit" ]
; then
+ i
f autoload -U compinit && [ -f "/usr/share/zsh/$ZSH_VERSION/functions/Completion/compinit" ] && compinit 2>/dev/null
; then
compinit
else
print 'Notice: no compinit available :('
compinit
else
print 'Notice: no compinit available :('
@@
-151,14
+150,19
@@
fi
fi
is4 && autoload -U zed # use ZLE editor to edit a file or function
fi
is4 && autoload -U zed # use ZLE editor to edit a file or function
- is4 && zmodload -i zsh/complist
- is4 && zmodload -i zsh/deltochar
- is4 && zmodload -i zsh/mathfunc
+ is4 && \
+ for mod in complist deltochar mathfunc ; do
+ zmodload -i zsh/${mod}
+ done
# autoload zsh modules when they are referenced
# autoload zsh modules when they are referenced
- is4 && zmodload -a zsh/stat stat
- is4 && zmodload -a zsh/zpty zpty
- is4 && zmodload -a zsh/zprof zprof
- is4 && zmodload -ap zsh/mapfile mapfile
+ is4 && \
+ for opt mod in a stat \
+ a zpty \
+ a zprof \
+ ap mapfile ; do
+ zmodload -${opt} zsh/${mod} ${mod}
+ done
+ unset opt mod
is4 && autoload -U insert-files && \
zle -N insert-files && \
is4 && autoload -U insert-files && \
zle -N insert-files && \
@@
-172,6
+176,9
@@
fi
zle -N edit-command-line && \
bindkey '\ee' edit-command-line
zle -N edit-command-line && \
bindkey '\ee' edit-command-line
+## menu selection: pick item but stay in the menu (press esc-return)
+ is4 && bindkey -M menuselect '\e^M' accept-and-menu-complete
+
# press "ctrl-e d" to insert the actual date in the form yyyy-mm-dd
_bkdate() { BUFFER="$BUFFER$(date '+%F')"; CURSOR=$#BUFFER; }
bindkey '\C-ed' _bkdate
# press "ctrl-e d" to insert the actual date in the form yyyy-mm-dd
_bkdate() { BUFFER="$BUFFER$(date '+%F')"; CURSOR=$#BUFFER; }
bindkey '\C-ed' _bkdate
@@
-280,19
+287,21
@@
fi
# }}}
# {{{ set prompt
# }}}
# {{{ set prompt
- if [ -f "/usr/share/zsh/$ZSH_VERSION/functions/Prompts/promptinit" ] ; then
-
autoload promptinit &&
promptinit # people should be able to use their favourite prompt
+ if [ -f "/usr/share/zsh/$ZSH_VERSION/functions/Prompts/promptinit" ]
&& autoload promptinit && promptinit 2>/dev/null
; then
+ promptinit # people should be able to use their favourite prompt
else
else
- print 'Notice: no promp
i
init available :('
+ print 'Notice: no promp
t
init available :('
fi
# precmd() => a function which is executed just before each prompt
# precmd () { setopt promptsubst; [[ -o interactive ]] && jobs -l;
# run 'NOPRECMD=1 zsh' to disable the precmd + preexec commands
is4 && ! [[ -n "$NOPRECMD" ]] && precmd () {
if [ -n "$BATTERY" ] ; then
fi
# precmd() => a function which is executed just before each prompt
# precmd () { setopt promptsubst; [[ -o interactive ]] && jobs -l;
# run 'NOPRECMD=1 zsh' to disable the precmd + preexec commands
is4 && ! [[ -n "$NOPRECMD" ]] && precmd () {
if [ -n "$BATTERY" ] ; then
- RPROMPT="%(?..:()% ${PERCENT}${SCREENTITLE}"
+ # RPROMPT="%(?..:()% ${PERCENT}${SCREENTITLE}"
+ RPROMPT="${PERCENT}${SCREENTITLE}"
else
else
- RPROMPT="%(?..:()% ${SCREENTITLE}"
+ # RPROMPT="%(?..:()% ${SCREENTITLE}"
+ RPROMPT="${SCREENTITLE}"
fi
# adjust title of xterm
# see http://www.faqs.org/docs/Linux-mini/Xterm-Title.html
fi
# adjust title of xterm
# see http://www.faqs.org/docs/Linux-mini/Xterm-Title.html
@@
-330,13
+339,24
@@
fi
esac
}
esac
}
+# set colors
+ if autoload colors && colors 2>/dev/null ; then
+ BLUE="%{${fg[blue]}%}"
+ RED="%{${fg_bold[red]}%}"
+ GREEN="%{${fg[green]}%}"
+ CYAN="%{${fg[cyan]}%}"
+ WHITE="%{${fg[white]}%}"
+ NO_COLOUR="%{${reset_color}%}"
+ else
+ BLUE="%{
\e
[1;34m%}"
+ RED="%{
\e
[1;31m%}"
+ GREEN="%{
\e
[1;32m%}"
+ CYAN="%{
\e
[1;36m%}"
+ WHITE="%{
\e
[1;37m%}"
+ NO_COLOUR="%{
\e
[0m%}"
+ fi
+
EXITCODE="%(?..%?%1v )"
EXITCODE="%(?..%?%1v )"
- local BLUE="%{
\e
[1;34m%}"
- local RED="%{
\e
[1;31m%}"
- local GREEN="%{
\e
[1;32m%}"
- local CYAN="%{
\e
[1;36m%}"
- local WHITE="%{
\e
[1;37m%}"
- local NO_COLOUR="%{
\e
[0m%}"
PS2='`%_> ' # secondary prompt, printed when the shell needs more information to complete a command.
PS3='?# ' # selection prompt used within a select loop.
PS4='+%N:%i:%_> ' # the execution trace prompt (setopt xtrace). default: '+%N:%i>'
PS2='`%_> ' # secondary prompt, printed when the shell needs more information to complete a command.
PS3='?# ' # selection prompt used within a select loop.
PS4='+%N:%i:%_> ' # the execution trace prompt (setopt xtrace). default: '+%N:%i>'
@@
-426,9
+446,13
@@
zsh-help - hints for use of zsh on grml
Main configuration of zsh happens in /etc/zsh/zshrc (global)
and /etc/skel/.zshrc which is copied to \$HOME/.zshrc once.
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, if you want to
+The files are part of the package grml-etc
-core
, if you want to
use them on a non-grml-system just get the tar.gz from
use them on a non-grml-system just get the tar.gz from
-http://grml.org/repos/
+http://grml.org/repos/ or get the files from the mercurial
+repository:
+
+ http://hg.grml.org/grml-etc-core/raw-file/tip/etc/skel/.zshrc
+ http://hg.grml.org/grml-etc-core/raw-file/tip/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
If you want to stay in sync with zsh configuration of grml
run 'ln -sf /etc/skel/.zshrc \$HOME/.zshrc' and configure
@@
-467,14
+491,15
@@
Enjoy your grml system with the zsh!$reset_color"
# debian stuff
if [ -r /etc/debian_version ] ; then
# debian stuff
if [ -r /etc/debian_version ] ; then
- alias acs="apt-cache search"
- alias acsh="apt-cache show"
+ alias acs='apt-cache search'
+ alias acsh='apt-cache show'
+ alias acp='apt-cache policy'
alias adg="$SUDO apt-get dist-upgrade"
alias agi="$SUDO apt-get install"
alias ag="$SUDO apt-get upgrade"
alias au="$SUDO apt-get update"
alias adg="$SUDO apt-get dist-upgrade"
alias agi="$SUDO apt-get install"
alias ag="$SUDO apt-get upgrade"
alias au="$SUDO apt-get update"
- alias dbp=
"dpkg-buildpackage"
- alias ge=
"grep-excuses"
+ alias dbp=
'dpkg-buildpackage'
+ alias ge=
'grep-excuses'
isgrmlcd && alias su="sudo su" # change to user root
alias tlog="tail -f /var/log/syslog" # take a look at the syslog
isgrmlcd && alias su="sudo su" # change to user root
alias tlog="tail -f /var/log/syslog" # take a look at the syslog
@@
-530,6
+555,7
@@
grmlcomp() {
zstyle ':completion:*:*:lintian:*' file-patterns '*.deb' # complete debian packages for command 'lintian'
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # match uppercase from lowercase
zstyle ':completion:*:matches' group 'yes' # separate matches into groups
zstyle ':completion:*:*:lintian:*' file-patterns '*.deb' # complete debian packages for command 'lintian'
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # match uppercase from lowercase
zstyle ':completion:*:matches' group 'yes' # separate matches into groups
+ zstyle ':completion:*' group-name ''
if [[ -z "$NOMENU" ]] ; then
zstyle ':completion:*' menu select=5 # if there are more than 5 options allow selecting from a menu
else
if [[ -z "$NOMENU" ]] ; then
zstyle ':completion:*' menu select=5 # if there are more than 5 options allow selecting from a menu
else
@@
-547,8
+573,9
@@
grmlcomp() {
zstyle ':completion::(^approximate*):*:functions' ignored-patterns '_*' # Ignore completion functions for commands you don't have:
# complete manual by their section
zstyle ':completion::(^approximate*):*:functions' ignored-patterns '_*' # Ignore completion functions for commands you don't have:
# complete manual by their section
- zstyle ':completion:*:manuals' separate-sections true
- zstyle ':completion:*:man:*' menu yes select
+ zstyle ':completion:*:manuals' separate-sections true
+ zstyle ':completion:*:manuals.*' insert-sections true
+ zstyle ':completion:*:man:*' menu yes select
## correction
# run rehash on completion so new installed program are found automatically:
## correction
# run rehash on completion so new installed program are found automatically:
@@
-578,6
+605,17
@@
grmlcomp() {
# zstyle ':completion:*' completer _complete _correct _approximate
# zstyle ':completion:*' expand prefix suffix
# zstyle ':completion:*' completer _complete _correct _approximate
# zstyle ':completion:*' expand prefix suffix
+# automatic rehash? Credits go to Frank Terbeck
+# function my_accept () {
+# local buf
+# [[ -z ${BUFFER} ]] && zle accept-line && return
+# buf=( ${(z)BUFFER} )
+# [[ -z ${commands[${buf[1]}]} ]] && rehash
+# zle accept-line
+# }
+# zle -N my_accept
+# bindkey "^M" my_accept
+
# command for process lists, the local web server details and host completion
hosts=(`hostname` grml.org)
zstyle '*' hosts $hosts
# command for process lists, the local web server details and host completion
hosts=(`hostname` grml.org)
zstyle '*' hosts $hosts
@@
-633,8
+671,7
@@
If you want to use xinit anyway please call \"/usr/bin/xinit\"."
alias grml-version='cat /etc/grml_version'
if [ -x /usr/sbin/rebuildfstab ] ; then
alias grml-version='cat /etc/grml_version'
if [ -x /usr/sbin/rebuildfstab ] ; then
- local fstabuser=$(getent passwd 1000 | cut -d: -f1)
- alias grml-rebuildfstab="rebuildfstab -v -r -u $fstabuser -g $fstabuser"
+ alias grml-rebuildfstab='rebuildfstab -v -r -config'
fi
}
# }}}
fi
}
# }}}
@@
-668,16
+705,34
@@
If you want to use xinit anyway please call \"/usr/bin/xinit\"."
setenv() { typeset -x "${1}${1:+=}${(@)argv[2,$#]}" } # csh compatibility
freload() { while (( $# )); do; unfunction $1; autoload -U $1; shift; done }
manzsh() { /usr/bin/man zshall | vim -c "se ft=man| se hlsearch" +/"$1" - ; }
setenv() { typeset -x "${1}${1:+=}${(@)argv[2,$#]}" } # csh compatibility
freload() { while (( $# )); do; unfunction $1; autoload -U $1; shift; done }
manzsh() { /usr/bin/man zshall | vim -c "se ft=man| se hlsearch" +/"$1" - ; }
+# manzsh() { /usr/bin/man zshall | most +/"$1" ; }
# manzsh() { man zshall | $MYLESS -p $1 ; }
# manzsh() { man zshall | $MYLESS -p $1 ; }
-# manzsh() { /usr/bin/man zshall | most +/"$1" ; }
# use "dchange <package-name>" to view Debian's changelog of the package:
# use "dchange <package-name>" to view Debian's changelog of the package:
- dchange() { most /usr/share/doc/${1}/changelog.Debian.gz ; }
+ dchange() {
+ if [ -r /usr/share/doc/${1}/changelog.Debian.gz ] ; then
+ most /usr/share/doc/${1}/changelog.Debian.gz
+ else
+ if [ -r /usr/share/doc/${1}/changelog.gz ] ; then
+ most /usr/share/doc/${1}/changelog.gz
+ else
+ echo "No changelog for package $1 found, sorry."
+ return 1
+ fi
+ fi
+ }
_dchange() { _files -W /usr/share/doc -/ }
compdef _dchange dchange
# use "uchange <package-name>" to view upstream's changelog of the package:
_dchange() { _files -W /usr/share/doc -/ }
compdef _dchange dchange
# use "uchange <package-name>" to view upstream's changelog of the package:
- uchange() { most /usr/share/doc/${1}/changelog.gz ; }
+ uchange() {
+ if [ -r /usr/share/doc/${1}/changelog.gz ] ; then
+ most /usr/share/doc/${1}/changelog.gz
+ else
+ echo "No changelog for package $1 found, sorry."
+ return 1
+ fi
+ }
_uchange() { _files -W /usr/share/doc -/ }
compdef _uchange uchange
_uchange() { _files -W /usr/share/doc -/ }
compdef _uchange uchange
@@
-696,13
+751,16
@@
If you want to use xinit anyway please call \"/usr/bin/xinit\"."
# use it e.g. via 'Restart apache2'
if [ -d /etc/init.d ] ; then
for i in Start Restart Stop Reload ; do
# use it e.g. via 'Restart apache2'
if [ -d /etc/init.d ] ; then
for i in Start Restart Stop Reload ; do
- eval "$i() { $SUDO /etc/init.d/\$1 ${i:l} $2 ; }"
+ eval "$i() { $SUDO /etc/init.d/\$1 ${i:l}
\
$2 ; }"
done
# now the completion for this:
compctl -g "$(echo /etc/init.d/*(:t))" Start Restart Stop Reload
fi
# }}}
done
# now the completion for this:
compctl -g "$(echo /etc/init.d/*(:t))" Start Restart Stop Reload
fi
# }}}
+# make sure our environment is clean regarding colors
+ for color in BLUE RED GREEN CYAN WHITE ; unset $color
+
# source another config file if present {{{
if [ -r /etc/zsh/zshrc.local ]; then
source /etc/zsh/zshrc.local
# source another config file if present {{{
if [ -r /etc/zsh/zshrc.local ]; then
source /etc/zsh/zshrc.local