# 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: Wed Aug 06 23:50:53 CEST 2008 [mika]
################################################################################
# This file is sourced only for interactive shells. It
# should contain commands to set up aliases, functions,
# zsh profiling {{{
# just execute 'ZSH_PROFILE_RC=1 zsh' and run 'zprof' to get the details
-if [[ -n $ZSH_PROFILE_RC ]] ; then
+if [[ $ZSH_PROFILE_RC -gt 0 ]] ; then
zmodload zsh/zprof
fi
# }}}
+# setting some default values {{{
+NOCOR=${NOCOR:-0}
+NOMENU=${NOMENU:-0}
+NOPRECMD=${NOPRECMD:-0}
+BATTERY=${BATTERY:-0}
+# }}}
+
# {{{ check for version/system
# check for versions (compatibility reasons)
is4(){
[[ -d /etc/zsh/completion.d ]] && fpath=( $fpath /etc/zsh/completion.d )
if [[ -d /etc/zsh/functions.d ]] ; then
fpath+=( /etc/zsh/functions.d )
- for func in /etc/zsh/functions.d/[^_]*[^~] ; do
+ for func in /etc/zsh/functions.d/[^_]*[^~](N.) ; do
zrcautoload -U ${func:t}
done
fi
tmpargs=(
a stat
a zpty
- ap zprof
ap mapfile
)
# }}}
# {{{ display battery status on right side of prompt via running 'BATTERY=1 zsh'
-if [[ -n "$BATTERY" ]] ; then
- if check_com -c acpi ; then
- PERCENT="${(C)${(s| |)$(acpi 2>/dev/null)}[4]}"
- [[ -z "$PERCENT" ]] && PERCENT='acpi not present'
+if [[ $BATTERY -gt 0 ]] ; then
+ if ! check_com -c acpi ; then
+ BATTERY=0
+ fi
+fi
- if [[ "${PERCENT%%%}" -lt 20 ]] ; then
- PERCENT="warning: ${PERCENT}%"
+battery() {
+if [[ $BATTERY -gt 0 ]] ; then
+ PERCENT="${${"$(acpi 2>/dev/null)"}/(#b)[[:space:]]##Battery <->: [^0-9]##, (<->)%*/${match[1]}}"
+ if [[ -z "$PERCENT" ]] ; then
+ PERCENT='acpi not present'
+ else
+ if [[ "$PERCENT" -lt 20 ]] ; then
+ PERCENT="warning: ${PERCENT}%%"
+ else
+ PERCENT="${PERCENT}%%"
fi
fi
fi
+}
# }}}
# set colors for use in prompts {{{
# which distributed under the same terms as zsh itself.
# we will only be using one variable, so let the code know now.
-zstyle ':vcs_info:*' maxexports 1
+zstyle ':vcs_info:*' max-exports 1
# vcs_info() documentation:
#{{{
# make sure to use right prompt only when not running a command
is41 && setopt transient_rprompt
-is4 && [[ -z $NOPRECMD ]] && precmd () {
- [[ -n $NOPRECMD ]] && return 0
+is4 && [[ $NOPRECMD -eq 0 ]] && precmd () {
+ [[ $NOPRECMD -gt 0 ]] && return 0
# update VCS information
vcs_info
# return 0
fi
# just use DONTSETRPROMPT=1 to be able to overwrite RPROMPT
- if [[ -z $DONTSETRPROMPT ]] ; then
- if [[ -n $BATTERY ]] ; then
+ if [[ $DONTSETRPROMPT -eq 0 ]] ; then
+ if [[ $BATTERY -gt 0 ]] ; then
+ # update BATTERY information
+ battery
RPROMPT="%(?..:()% ${PERCENT}${SCREENTITLE}"
# RPROMPT="${PERCENT}${SCREENTITLE}"
else
}
# preexec() => a function running before every command
-is4 && [[ -z $NOPRECMD ]] && \
+is4 && [[ $NOPRECMD -eq 0 ]] && \
preexec () {
- [[ -n $NOPRECMD ]] && return 0
+ [[ $NOPRECMD -gt 0 ]] && return 0
# set hostname if not running on host with name 'grml'
if [[ -n "$HOSTNAME" ]] && [[ "$HOSTNAME" != $(hostname) ]] ; then
NAME="@$HOSTNAME"
# don't use colors on dumb terminals (like emacs):
if [[ "$TERM" == dumb ]] ; then
- PROMPT="${EXITCODE}${debian_chroot:+($debian_chroot)}%n@%m %40<...<%B%~%b%<< "'${VCS_INFO_message_}'"%# "
+ PROMPT="${EXITCODE}${debian_chroot:+($debian_chroot)}%n@%m %40<...<%B%~%b%<< "'${VCS_INFO_message_0_}'"%# "
else
# only if $GRMLPROMPT is set (e.g. via 'GRMLPROMPT=1 zsh') use the extended prompt
# set variable identifying the chroot you work in (used in the prompt below)
- if [[ -n $GRMLPROMPT ]] ; then
+ if [[ $GRMLPROMPT -gt 0 ]] ; then
PROMPT="${RED}${EXITCODE}${CYAN}[%j running job(s)] ${GREEN}{history#%!} ${RED}%(3L.+.) ${BLUE}%* %D
${BLUE}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< %# "
else
# This assembles the primary prompt string
if (( EUID != 0 )); then
- PROMPT="${RED}${EXITCODE}${WHITE}${debian_chroot:+($debian_chroot)}${BLUE}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< "'${VCS_INFO_message_}'"%# "
+ PROMPT="${RED}${EXITCODE}${WHITE}${debian_chroot:+($debian_chroot)}${BLUE}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< "'${VCS_INFO_message_0_}'"%# "
else
- PROMPT="${BLUE}${EXITCODE}${WHITE}${debian_chroot:+($debian_chroot)}${RED}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< "'${VCS_INFO_message_}'"%# "
+ PROMPT="${BLUE}${EXITCODE}${WHITE}${debian_chroot:+($debian_chroot)}${RED}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< "'${VCS_INFO_message_0_}'"%# "
fi
fi
fi
# set up software synthesizer via speakup
swspeak() {
- 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
- else
- setopt singlelinezle
- unsetopt prompt_cr
- export PS1="%m%# "
- nice -n -20 speechd-up
- sleep 2
- flite -o play -t "Finished setting up software synthesizer"
- fi
+ if [ -x /usr/sbin/swspeak-setup ] ; then
+ setopt singlelinezle
+ unsetopt prompt_cr
+ 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
+ else
+ setopt singlelinezle
+ unsetopt prompt_cr
+ export PS1="%m%# "
+ nice -n -20 speechd-up
+ sleep 2
+ flite -o play -t "Finished setting up software synthesizer"
+ fi
+ fi
}
# I like clean prompt, so provide simple way to get that
http://deb.grml.org/ 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
+ 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
If you want to stay in sync with zsh configuration of grml
run '\''ln -sf /etc/skel/.zshrc $HOME/.zshrc'\'' and configure
the zsh yet. :)
"NOCOR=1 zsh" => deactivate automatic correction
- "NOMENU=1 zsh" => do not use menu completion (note: use strg-d for completion instead!)
+ "NOMENU=1 zsh" => do not use auto menu completion (note: use ctrl-d for completion instead!)
"NOPRECMD=1 zsh" => disable the precmd + preexec commands (set GNU screen title)
- "BATTERY=1 zsh" => activate battery status (via acpi) on right side of prompt'
+ "BATTERY=1 zsh" => activate battery status (via acpi) on right side of prompt
+
+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
+zshrc.'
print "
$bg[white]$fg[black]
zstyle ':completion:*:matches' group 'yes'
zstyle ':completion:*' group-name ''
- if [[ -z "$NOMENU" ]] ; then
+ if [[ "$NOMENU" -eq 0 ]] ; then
# if there are more than 5 options allow selecting from a menu
zstyle ':completion:*' menu select=5
else
## correction
# some people don't like the automatic correction - so run 'NOCOR=1 zsh' to deactivate it
- if [[ -n "$NOCOR" ]] ; then
+ if [[ "$NOCOR" -gt 0 ]] ; then
zstyle ':completion:*' completer _oldlist _expand _force_rehash _complete _files _ignored
setopt nocorrect
else