X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=etc%2Fzsh%2Fzshrc;h=94420c73b57fdf37c983c01713fbb2da3d2cf32e;hb=6a512b0c54fdc39142b1015386992387d68aab86;hp=5f832c7f27707318041833f80c6ae7179ed83b33;hpb=08ab5d927b758f7f3445d0dd57b6f9076d1636ca;p=grml-etc-core.git diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 5f832c7..94420c7 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -985,6 +985,17 @@ for rh in run-help{,-git,-svk,-svn}; do zrcautoload $rh done; unset rh +# command not found handling + +(( ${COMMAND_NOT_FOUND} == 1 )) && +function command_not_found_handler() { + emulate -L zsh + if [[ -x ${GRML_ZSH_CNF_HANDLER} ]] ; then + ${GRML_ZSH_CNF_HANDLER} $1 + fi + return 1 +} + # completion system if zrcautoload compinit ; then compinit || print 'Notice: no compinit available :(' @@ -1240,8 +1251,6 @@ PS4='+%N:%i:%_> ' # - battery status # - debian_chroot # - vcs_info setup and version specific fixes -# - command-not-found handling -# (TODO: This has nothing to do with prompts: move!) # display battery status on right side of prompt via running 'BATTERY=1 zsh' if [[ $BATTERY -gt 0 ]] ; then @@ -1267,7 +1276,7 @@ fi # set variable debian_chroot if running in a chroot with /etc/debian_chroot if [[ -z "$debian_chroot" ]] && [[ -r /etc/debian_chroot ]] ; then - debian_chroot=$(cat /etc/debian_chroot) + debian_chroot=$( a function running before every command -is4 && [[ $NOPRECMD -eq 0 ]] && \ -preexec () { - [[ $NOPRECMD -gt 0 ]] && return 0 -# set hostname if not running on host with name 'grml' +function grml_maintain_name () { + # set hostname if not running on host with name 'grml' if [[ -n "$HOSTNAME" ]] && [[ "$HOSTNAME" != $(hostname) ]] ; then NAME="@$HOSTNAME" fi -# get the name of the program currently running and hostname of local machine -# set screen window title if running in a screen +} + +function grml_cmd_to_screen_title () { + # get the name of the program currently running and hostname of local + # machine set screen window title if running in a screen if [[ "$TERM" == screen* ]] ; then - # local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} # don't use hostname - local CMD="${1[(wr)^(*=*|sudo|ssh|-*)]}$NAME" # use hostname + local CMD="${1[(wr)^(*=*|sudo|ssh|-*)]}$NAME" ESC_print ${CMD} fi -# adjust title of xterm - [[ ${NOTITLE} -gt 0 ]] && return 0 +} + +function grml_control_xterm_title () { case $TERM in (xterm*|rxvt*) set_title "${(%):-"%n@%m:"}" "$1" @@ -1703,6 +1695,17 @@ preexec () { esac } +zrcautoload add-zsh-hook || add-zsh-hook () { :; } +if [[ $NOPRECMD -gt 0 ]]; then + add-zsh-hook precmd grml_reset_screen_title + add-zsh-hook precmd grml_vcs_to_screen_title + add-zsh-hook preexec grml_maintain_name + add-zsh-hook preexec grml_cmd_to_screen_title + if [[ $NOTITLE -eq 0 ]]; then + add-zsh-hook preexec grml_control_xterm_title + fi +fi + # 'hash' some often used directories #d# start hash -d deb=/var/cache/apt/archives