# -*- shell-script -*- # Joerg Arndt's .jjzshrc # ... online at http://www.jjj.de/ # your feedback is welcome mailto: arndt (AT) jjj.de # version: 2011-November-05 (12:17) ### ------- ZSH specific settings ------- # The following options are set if the shell is invoked as sh or ksh: # NO_BAD_PATTERN, NO_BANG_HIST, NO_BG_NICE, NO_EQUALS, NO_FUNC­ # TION_ARGZERO, GLOB_SUBST, NO_GLOBAL_EXPORT, NO_HUP, # INTERACTIVE_COMMENTS, KSH_ARRAYS, NO_MULTIOS, NO_NOMATCH, NO_NOTIFY, # POSIX_BUILTINS, NO_PROMPT_PERCENT, RM_STAR_SILENT, SH_FILE_EXPANSION, # SH_GLOB, SH_OPTION_LETTERS, SH_WORD_SPLIT. Additionally the BSD_ECHO # and IGNORE_BRACES options are set if zsh is invoked as sh. Also, the # KSH_OPTION_PRINT, LOCAL_OPTIONS, PROMPT_BANG, PROMPT_SUBST and # SINGLE_LINE_ZLE options are set if zsh is invoked as ksh. #WORDCHARS='*?_-.[]~=/&;!#$%^(){}<>' WORDCHARS='' SAVEHIST=$HISTSIZE function h { history -10; } function hh { history -40; } function hhh { history 0; } alias help=run-help ## options: man zshoptions; check with: set -o set -o shwordsplit set -o globsubst set -o histverify set -o hist_reduce_blanks set +o nomatch set -o notify set +o recexact set -o chaselinks set -o interactivecomments set -o nobadpattern set -o extendedhistory set -o magicequalsubst set -o print_exit_value ## ## Quote the whole line in '$( )': bindkey -s '^xq' '^e)^a $(^a' ## Quote the whole line in 'ee $( )': (ee == emacs) bindkey -s '^xe' '^e)^a $(^aee ' ## postpone but leave in history: #bindkey -s '^x-' '^a#^e\n' bindkey -s '\e#' '^a#^e\n' ## make alt-left and alt-right jump over words: bindkey '\e[1;3D' backward-word bindkey '\e[1;3C' forward-word #bindkey '^[1;5D' backward-word #bindkey '^[1;5C' forward-word #bindkey '\e[D' backward-char # OK ## make del-key work for stupid systems bindkey '\e[3~' delete-char bindkey '\e[5~' history-beginning-search-backward-end bindkey '\e[6~' history-beginning-search-forward-end bindkey '\e[F' end-of-line bindkey '\e[H' beginning-of-line bindkey '\e^?' backward-kill-word bindkey '\ed' kill-word #bindkey "^[[5C" emacs-forward-word #bindkey "^[[5D" emacs-backward-word #bindkey "^[[OC" emacs-forward-word #bindkey "^[[OD" emacs-backward-word ##bindkey "^[[C" emacs-forward-word ##bindkey "^[[D" emacs-backward-word #bindkey "^[OC" emacs-forward-word #bindkey "^[OD" emacs-backward-word ##bindkey "^[[1;5D" emacs-backward-word ##bindkey "^[[1;5C" emacs-forward-word #bindkey "^B" emacs-backward-word #bindkey "^W" delete-word ## Meta-p, Meta-n for history search: bindkey -s '\ep' '\exhistory-beginning-search-backward-end\n' bindkey -s '\en' '\exhistory-beginning-search-forward-end\n' # ## same with (ctrl-)pageup/down (does NOT work): #bindkey -s '\e[05~' '\exhistory-beginning-search-backward-end\n' #bindkey -s '\e[06~' '\exhistory-beginning-search-forward-end\n' ## logout: set +o ignoreeof #set -o ignoreeof #bindkey -s '^xd' '^aexit;\n' ## quick base-converter: bindkey -s '^x6' '^e ))^aecho $(( [#16] 10#' bindkey -s '^x1' '^e ))^aecho $(( [#10] 16#' bindkey -s '^x2' '^e ))^aecho $(( [#2] 10#' bindkey -s '^x0' '^e ))^aecho $(( [#10] 10#' bindkey -s '^xf' '^afind . -name \\*' ## show type of command: #bindkey -s '^xp' '^atype -a \n\e[A^a\ed\ed' ## list 3 newest files and init cmdline with newest file: #bindkey -s '^xl' '^a\\ls -tr1 | tail -3 \n\e[A^a\ed\ed $(\\ls -tr1 | tail -1^e)^a' ## Executed whenever a command has a non-zero exit status: #TRAPZERR() { echo 'Oink!'; } # ===== stuff for prompts: ===== # unset PS1 export ME="$USER@$HOSTNAME"; if [ -n "$DISPLAY" ]; then # xterm: settings for white background PP1="%{${GREEN}%}%*%{${NORMAL}%}" PP2="%n@%m:" PP3="%{${BLUE}%}%~/%{${NORMAL}%}" else PP1="%{${BRIGHT}${GREEN}%}%*%{${NORMAL}%}" PP2="%n@%m:" PP3="%{${BRIGHT}${BLUE}%}%~/%{${NORMAL}%}" fi # echo number of jobs iff it is >0: # JOBSQ='%(1j. [%j].)' JOBSQ="%(1j. [%{$MAGENTA%}%j%{$NORMAL%}].)" # unset JOBSQ PS1="${PP1} ${PP2}${PP3}"; if [ "$EUID" = "0" ]; then # append '#' to prompt: PS1="$PS1$JOBSQ %{${BRIGHT}${RED}%}%%%{${NORMAL}%} " else PS1="$PS1$JOBSQ %% " fi unset PP1 PP2 PP3 export TPS1="$PS1"'\n'"%% " ; # does not work PS2="%{$MAGENTA%}>>%{$NORMAL%}" export PS1; export PS2; # ===== end (prompts) ===== if [ -n "$DISPLAY" ]; then # set PROMPT_COMMAND: # chpwd: Executed whenever the current working directory is changed. TAPP=" __ $(uname -mr) __ $(date +' %A %d-%m-%Y')"; # PROMPT_COMMAND="echo -ne '\033]0;'$ME:\`dirs +0\`/' '$TAPP'\007'"; # precmd Executed before each prompt. # precmd() { echo -ne '\033]0;'"$ME:${PWD/${HOME}\//~/}"' '$TAPP'\007' }; precmd() { if test -z "$XTITLE"; then # echo -ne '\033]0;'"$ME:${PWD/#${HOME}/~}"' '$TAPP'\007'; echo -ne '\033]0;'"${PWD/#${HOME}/~} [$ME]"' '$TAPP'\007'; else echo -ne '\033]0;'"$XTITLE"'\007'; fi }; function pp { XTITLE="$@"; } # set xtitle to last part of dirname and full dirname: function p { export XTITLE="${PWD##*/} [$PWD]"; } function xtitle { if [ $# = 0 ]; then XTITLE=''; else XTITLE="$@"; fi } function xs ## cd to dir and set title, 'xs .' just puts dirname into title { cd $1; XTITLE="${PWD##*/} [$PWD]"; } #else # unset PROMPT_COMMAND; fi #export PROMPT_COMMAND;