X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=dotfiles%2Fshell%2F.zshrc;h=4e135a9b9afe9771409c884244f759a7df7cd116;hb=58dbef0f4c9b483070f21df665e86ed63f7388ad;hp=291c4ab2469f39ef41d3cf4f95a159b3cc1418c4;hpb=b18acf8193b93a4b1bae35708a628c6acc686e85;p=shutils.git diff --git a/dotfiles/shell/.zshrc b/dotfiles/shell/.zshrc index 291c4ab..4e135a9 100644 --- a/dotfiles/shell/.zshrc +++ b/dotfiles/shell/.zshrc @@ -14,7 +14,7 @@ zstyle ':completion::complete:*' use-cache 1 autoload colors zsh/terminfo if [[ "$terminfo[colors]" -ge 8 ]]; then - colors + colors fi eval `dircolors` @@ -24,9 +24,6 @@ zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} zstyle ':completion:*' menu select zmodload -i zsh/complist -#TERM=xterm-256color - - # bind special keys according to readline configuration #eval "$(sed -n 's/^/bindkey /; s/: / /p' /etc/inputrc)" @@ -57,28 +54,21 @@ bindkey "\e[8~" end-of-line setopt \ - EXTENDEDGLOB \ - BASH_AUTO_LIST \ - LIST_AMBIGUOUS \ - CHECK_JOBS \ - INC_APPEND_HISTORY \ - HIST_IGNORE_DUPS \ - HIST_IGNORE_SPACE \ - NO_HUP - - -for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do - eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}' - eval PR_LIGHT_$color='%{$fg[${(L)color}]%}' -done -PR_BOLD="%{$terminfo[bold]%}" -PR_NO_COLOUR="%{$terminfo[sgr0]%}" + EXTENDEDGLOB \ + BASH_AUTO_LIST \ + LIST_AMBIGUOUS \ + CHECK_JOBS \ + INC_APPEND_HISTORY \ + HIST_IGNORE_DUPS \ + HIST_IGNORE_SPACE \ + NO_HUP + HISTFILE=~/.zsh_history HISTSIZE=50000 SAVEHIST=50000 REPORTTIME=5 -TIMEFMT="$fg[magenta]%J %U user %S sys %P cpu %*E total %M kB max$terminfo[sgr0]" +TIMEFMT="$fg[magenta]%J %U user %S sys %P cpu %*E total %M MB RSS max$terminfo[sgr0]" autoload -Uz vcs_info && vcs_info zstyle ':vcs_info:*' enable git cvs svn hg @@ -88,44 +78,59 @@ zstyle ':vcs_info:*' max-exports 1 function setprompt() { - # default: " (%s)-[%b|%a]%u%c-" - zstyle ':vcs_info:*' actionformats " %s: %b|%a" - # default: " (%s)-[%b]%u%c-" - zstyle ':vcs_info:*' formats " %s: %b" + # default: " (%s)-[%b|%a]%u%c-" + zstyle ':vcs_info:*' actionformats " %s: %b|%a" + # default: " (%s)-[%b]%u%c-" + zstyle ':vcs_info:*' formats " %s: %b" - setopt PROMPT_SUBST - PROMPT=' + setopt PROMPT_SUBST + PROMPT=' %(!.%{$fg_bold[red]%}.%{$fg_bold[green]%})%n@%m%{$reset_color%}$PR_SCREEN$PR_JOBS%{$fg_bold[yellow]%}${vcs_info_msg_0_}%{$reset_color%} %{$fg_bold[blue]%}%~%{$reset_color%} $PR_EXIT%# ' } setprompt # Obtain the autofs mountpoints -autofs_mp="" -[ -r /etc/auto.master ] && autofs_mp=$(/bin/grep -e "^/" /etc/auto.master) +autofs_mp=() +[ -r /etc/auto.master ] && autofs_mp=($(/bin/grep -e "^/" /etc/auto.master | cut -f1)) function precmd () { - PR_EXIT="%{$fg_bold[red]%}%(?..[%?] )%{$reset_color%}" - - # autofs always complains not being able to mount .hg/ and the like - if echo "$autofs_mp" | /bin/grep -qe "^$PWD\s"; then - vcs_info_msg_0_="[autofs]" - else - vcs_info - fi - - PR_SCREEN="" - if [[ -n "${WINDOW}" ]]; then - PR_SCREEN=" S:${WINDOW}" - fi - - PR_JOBS="" - if [[ $(jobs | wc -l) -gt 0 ]]; then - PR_JOBS=" J:%j" - fi + PR_EXIT="%{$fg_bold[red]%}%(?..[%?] )%{$reset_color%}" + + # Check whether current directory is a subdirectory of an autofs mountpoint + local parent="0" + vcs_info_msg_0_="" + for mp in ${autofs_mp}; do + # A parent directory is an autofs mount point + if echo "$PWD" | /bin/grep -q $mp; then + parent="1" + # Even equal! + if echo "$mp" | /bin/grep -q $PWD; then + vcs_info_msg_0_=" [autofs]" + fi + break; + fi + done + + if [ -z "$vcs_info_msg_0_" ]; then + if [ "$parent" = "1" ]; then + # svn and hg cause complaints of autofs that .svn and .hg is no mount point + zstyle ':vcs_info:*' enable git cvs + else + zstyle ':vcs_info:*' enable git cvs svn hg + fi + vcs_info + fi + + PR_SCREEN="" + if [[ -n "${WINDOW}" ]]; then + PR_SCREEN=" S:${WINDOW}" + fi + + PR_JOBS="" + if [[ $(jobs | wc -l) -gt 0 ]]; then + PR_JOBS=" J:%j" + fi } - - -