From 68ec4350d9f8a7b7ef293be998ad7fa12bdf382a Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Mon, 17 Mar 2008 10:16:51 +0100 Subject: Converts '"' into ''' because of some special escape sequences.. --- user:hugues/KeyBindings.zsh | 366 ++++++++++++++++++++++---------------------- 1 file changed, 183 insertions(+), 183 deletions(-) diff --git a/user:hugues/KeyBindings.zsh b/user:hugues/KeyBindings.zsh index 2b1eb81..2fdb66e 100644 --- a/user:hugues/KeyBindings.zsh +++ b/user:hugues/KeyBindings.zsh @@ -14,41 +14,41 @@ # Lancez un chtit bindkey dans votre zsh pour voir... # -bindkey "[3~" delete-char # delete -bindkey "[2~" overwrite-mode # insert -bindkey "" up-line-or-history # up -bindkey "" down-line-or-history # down -bindkey "" history-search-backward # META-up -bindkey "" history-search-forward # META-down -bindkey "" forward-word # ESC right -bindkey "" backward-word # ESC left -bindkey "[3~" kill-region # ESC del +bindkey '[3~' delete-char # delete +bindkey '[2~' overwrite-mode # insert +bindkey '' up-line-or-history # up +bindkey '' down-line-or-history # down +bindkey '' history-search-backward # META-up +bindkey '' history-search-forward # META-down +bindkey '' forward-word # ESC right +bindkey '' backward-word # ESC left +bindkey '[3~' kill-region # ESC del # Pratique pour rehasher rapidement -bindkey -s "r" "Q rehash\n" +bindkey -s 'r' 'Q rehash\n' # Exécute la commande ``rt'' qui me permet de nettoyer toutes les saletés -bindkey -s "R" "Q rt\n" +bindkey -s 'R' 'Q rt\n' -test $TERM = "rxvt" -o $TERM = "xterm" -o $TERM = "aterm" && +test $TERM = 'rxvt' -o $TERM = 'xterm' -o $TERM = 'aterm' && { - bindkey "[1~" beginning-of-line # home - bindkey "[4~" end-of-line # end-of-line - bindkey "Oc" forward-word # CTRL right - bindkey "Od" backward-word # CTRL left - bindkey "[3$" vi-set-buffer # SHIFT del - bindkey "Oa" history-search-backward # CTRL UP - bindkey "Ob" history-search-forward # CTRL DOWN + bindkey '[1~' beginning-of-line # home + bindkey '[4~' end-of-line # end-of-line + bindkey 'Oc' forward-word # CTRL right + bindkey 'Od' backward-word # CTRL left + bindkey '[3$' vi-set-buffer # SHIFT del + bindkey 'Oa' history-search-backward # CTRL UP + bindkey 'Ob' history-search-forward # CTRL DOWN } # (gnome-terminal) -test $TERM = "xterm" && +test $TERM = 'xterm' && { - bindkey "OH" beginning-of-line # home - bindkey "OF" end-of-line # end-of-line + bindkey 'OH' beginning-of-line # home + bindkey 'OF' end-of-line # end-of-line } -#bindkey "\C-t" gosmacs-transpose-chars # J, ca c'est un truc pour toi +#bindkey '\C-t' gosmacs-transpose-chars # J, ca c'est un truc pour toi # ne pas oublier de s'en servir : # vi-match-bracket est sur ^X^B par defaut -# npo : quote-region est sur ESC-" par defaut +# npo : quote-region est sur ESC-' par defaut # npo : which-command est sur ESC-? par defaut # Lancez ``bindkey'' pour en savoir plus !! @@ -56,170 +56,170 @@ test $TERM = "xterm" && ## Résultat d'un ``bindkey'' -bindkey "#" set-mark-command -bindkey "^A" beginning-of-line -bindkey "^B" backward-char -bindkey "^D" delete-char-or-list -bindkey "^E" end-of-line -bindkey "^F" forward-char -bindkey "^G" send-break -bindkey "^H" backward-delete-char -bindkey "^I" expand-or-complete -bindkey "^J" accept-line -bindkey "^K" kill-line -bindkey "^L" clear-screen -bindkey "^M" accept-line -bindkey "^N" down-line-or-history -bindkey "^O" accept-line-and-down-history -bindkey "^P" up-line-or-history -bindkey "^Q" push-line -bindkey "^R" history-incremental-search-backward -bindkey "^S" history-incremental-search-forward -bindkey "^T" transpose-chars -bindkey "^U" kill-whole-line -bindkey "^V" quoted-insert -bindkey "^W" backward-kill-word -bindkey "^X^B" vi-match-bracket -bindkey "^X^F" vi-find-next-char -bindkey "^X^J" vi-join -bindkey "^X^K" kill-buffer -bindkey "^X^N" infer-next-history -bindkey "^X^O" overwrite-mode -bindkey "^X^R" _read_comp -bindkey "^X^U" undo -#bindkey "^X^V" vi-cmd-mode -bindkey "^X^X" exchange-point-and-mark -bindkey "^X*" expand-word -bindkey "^X=" what-cursor-position -bindkey "^X?" _complete_debug -bindkey "^XC" _correct_filename -bindkey "^XG" list-expand -bindkey "^Xa" _expand_alias -bindkey "^Xc" _correct_word -bindkey "^Xd" _list_expansions -bindkey "^Xe" _expand_word -bindkey "^Xg" list-expand -bindkey "^Xh" _complete_help -bindkey "^Xm" _most_recent_file -bindkey "^Xn" _next_tags -bindkey "^Xr" history-incremental-search-backward -bindkey "^Xs" history-incremental-search-forward -bindkey "^Xt" _complete_tag -bindkey "^Xu" undo -bindkey "^X~" _bash_list-choices -bindkey "^Y" yank -bindkey "^D" list-choices -bindkey "^G" send-break -bindkey "^H" backward-kill-word -bindkey "^I" self-insert-unmeta -bindkey "^J" self-insert-unmeta -bindkey "^L" clear-screen -bindkey "^M" self-insert-unmeta -bindkey "[3~" kill-region -bindkey "" history-search-backward -bindkey "" history-search-forward -bindkey "" forward-word -bindkey "" backward-word -bindkey "^_" copy-prev-word -bindkey " " magic-space -bindkey "!" expand-history -bindkey "\"" quote-region -bindkey "\$" spell-word -bindkey "'" quote-line #'" -bindkey "," _history-complete-newer -bindkey "-" neg-argument -bindkey "." insert-last-word -bindkey "/" _history-complete-older -bindkey "0" digit-argument -bindkey "1" digit-argument -bindkey "2" digit-argument -bindkey "3" digit-argument -bindkey "4" digit-argument -bindkey "5" digit-argument -bindkey "6" digit-argument -bindkey "7" digit-argument -bindkey "8" digit-argument -bindkey "9" digit-argument -bindkey "<" beginning-of-buffer-or-history -bindkey ">" end-of-buffer-or-history -bindkey "?" which-command -bindkey "A" accept-and-hold -bindkey "B" backward-word -bindkey "C" capitalize-word -bindkey "D" kill-word -bindkey "F" forward-word -bindkey "G" get-line -bindkey "H" run-help -bindkey "L" down-case-word -bindkey "N" history-search-forward -bindkey "OA" up-line-or-history -bindkey "OB" down-line-or-history -bindkey "OC" forward-char -bindkey "OD" backward-char -bindkey "P" history-search-backward -bindkey "Q" push-line -bindkey "S" spell-word -bindkey "T" transpose-words -bindkey "U" up-case-word -bindkey "W" copy-region-as-kill -bindkey "[1~" beginning-of-line -bindkey "[2~" overwrite-mode -bindkey "[3~" delete-char -bindkey "[4~" end-of-line -bindkey "[5~" history-beginning-search-backward-end -bindkey "[6~" history-beginning-search-forward-end -bindkey "" up-line-or-history -bindkey "" down-line-or-history -bindkey "" forward-char -bindkey "" backward-char -bindkey "_" insert-last-word -bindkey "a" accept-and-hold -bindkey "b" backward-word -bindkey "c" capitalize-word -bindkey "d" kill-word -bindkey "f" forward-word -bindkey "g" get-line -bindkey "h" run-help -bindkey "l" down-case-word -bindkey "n" history-search-forward -bindkey "p" history-search-backward -bindkey "q" push-line -bindkey "s" spell-word -bindkey "t" transpose-words -bindkey "u" up-case-word -bindkey "w" copy-region-as-kill -bindkey "x" execute-named-cmd -bindkey "y" yank-pop -bindkey "z" execute-last-named-cmd -bindkey "|" vi-goto-column -bindkey "~" _bash_complete-word -bindkey "^?" backward-kill-word -bindkey "^\" up-history -bindkey "^\" down-history -bindkey "^\" forward-char -bindkey "^\" backward-char -bindkey "^_" undo -bindkey " "-"~" self-insert -bindkey "" backward-delete-char -bindkey "\M-^@"-"\M-" self-insert +bindkey '#' set-mark-command +bindkey '^A' beginning-of-line +bindkey '^B' backward-char +bindkey '^D' delete-char-or-list +bindkey '^E' end-of-line +bindkey '^F' forward-char +bindkey '^G' send-break +bindkey '^H' backward-delete-char +bindkey '^I' expand-or-complete +bindkey '^J' accept-line +bindkey '^K' kill-line +bindkey '^L' clear-screen +bindkey '^M' accept-line +bindkey '^N' down-line-or-history +bindkey '^O' accept-line-and-down-history +bindkey '^P' up-line-or-history +bindkey '^Q' push-line +bindkey '^R' history-incremental-search-backward +bindkey '^S' history-incremental-search-forward +bindkey '^T' transpose-chars +bindkey '^U' kill-whole-line +bindkey '^V' quoted-insert +bindkey '^W' backward-kill-word +bindkey '^X^B' vi-match-bracket +bindkey '^X^F' vi-find-next-char +bindkey '^X^J' vi-join +bindkey '^X^K' kill-buffer +bindkey '^X^N' infer-next-history +bindkey '^X^O' overwrite-mode +bindkey '^X^R' _read_comp +bindkey '^X^U' undo +#bindkey '^X^V' vi-cmd-mode +bindkey '^X^X' exchange-point-and-mark +bindkey '^X*' expand-word +bindkey '^X=' what-cursor-position +bindkey '^X?' _complete_debug +bindkey '^XC' _correct_filename +bindkey '^XG' list-expand +bindkey '^Xa' _expand_alias +bindkey '^Xc' _correct_word +bindkey '^Xd' _list_expansions +bindkey '^Xe' _expand_word +bindkey '^Xg' list-expand +bindkey '^Xh' _complete_help +bindkey '^Xm' _most_recent_file +bindkey '^Xn' _next_tags +bindkey '^Xr' history-incremental-search-backward +bindkey '^Xs' history-incremental-search-forward +bindkey '^Xt' _complete_tag +bindkey '^Xu' undo +bindkey '^X~' _bash_list-choices +bindkey '^Y' yank +bindkey '^D' list-choices +bindkey '^G' send-break +bindkey '^H' backward-kill-word +bindkey '^I' self-insert-unmeta +bindkey '^J' self-insert-unmeta +bindkey '^L' clear-screen +bindkey '^M' self-insert-unmeta +bindkey '[3~' kill-region +bindkey '' history-search-backward +bindkey '' history-search-forward +bindkey '' forward-word +bindkey '' backward-word +bindkey '^_' copy-prev-word +bindkey ' ' magic-space +bindkey '!' expand-history +bindkey '\'' quote-region +bindkey '\$' spell-word +bindkey ''' quote-line #'' +bindkey ',' _history-complete-newer +bindkey '-' neg-argument +bindkey '.' insert-last-word +bindkey '/' _history-complete-older +bindkey '0' digit-argument +bindkey '1' digit-argument +bindkey '2' digit-argument +bindkey '3' digit-argument +bindkey '4' digit-argument +bindkey '5' digit-argument +bindkey '6' digit-argument +bindkey '7' digit-argument +bindkey '8' digit-argument +bindkey '9' digit-argument +bindkey '<' beginning-of-buffer-or-history +bindkey '>' end-of-buffer-or-history +bindkey '?' which-command +bindkey 'A' accept-and-hold +bindkey 'B' backward-word +bindkey 'C' capitalize-word +bindkey 'D' kill-word +bindkey 'F' forward-word +bindkey 'G' get-line +bindkey 'H' run-help +bindkey 'L' down-case-word +bindkey 'N' history-search-forward +bindkey 'OA' up-line-or-history +bindkey 'OB' down-line-or-history +bindkey 'OC' forward-char +bindkey 'OD' backward-char +bindkey 'P' history-search-backward +bindkey 'Q' push-line +bindkey 'S' spell-word +bindkey 'T' transpose-words +bindkey 'U' up-case-word +bindkey 'W' copy-region-as-kill +bindkey '[1~' beginning-of-line +bindkey '[2~' overwrite-mode +bindkey '[3~' delete-char +bindkey '[4~' end-of-line +bindkey '[5~' history-beginning-search-backward-end +bindkey '[6~' history-beginning-search-forward-end +bindkey '' up-line-or-history +bindkey '' down-line-or-history +bindkey '' forward-char +bindkey '' backward-char +bindkey '_' insert-last-word +bindkey 'a' accept-and-hold +bindkey 'b' backward-word +bindkey 'c' capitalize-word +bindkey 'd' kill-word +bindkey 'f' forward-word +bindkey 'g' get-line +bindkey 'h' run-help +bindkey 'l' down-case-word +bindkey 'n' history-search-forward +bindkey 'p' history-search-backward +bindkey 'q' push-line +bindkey 's' spell-word +bindkey 't' transpose-words +bindkey 'u' up-case-word +bindkey 'w' copy-region-as-kill +bindkey 'x' execute-named-cmd +bindkey 'y' yank-pop +bindkey 'z' execute-last-named-cmd +bindkey '|' vi-goto-column +bindkey '~' _bash_complete-word +bindkey '^?' backward-kill-word +bindkey '^\' up-history +bindkey '^\' down-history +bindkey '^\' forward-char +bindkey '^\' backward-char +bindkey '^_' undo +bindkey ' '-'~' self-insert +bindkey '' backward-delete-char +bindkey '\M-^@'-'\M-' self-insert # Raccourcis pour les todo : funny :) -# "q" stands for "push-line" -bindkey -s "t" "Q todo\n" -#bindkey -s "T" "Q todo all -c\n" +# 'q' stands for 'push-line' +bindkey -s 't' 'Q todo\n' +#bindkey -s 'T' 'Q todo all -c\n' -bindkey -s "é" " 2>/dev/null " -bindkey -s "2" " 2>&1 " +bindkey -s 'é' ' 2>/dev/null ' +bindkey -s '2' ' 2>&1 ' -bindkey -s "m" "Q mails\n" -bindkey -s "M" "make " +bindkey -s 'm' 'Q mails\n' +bindkey -s 'M' 'make ' -bindkey -s "l" "Q l\n" -#bindkey -s "L" "Q la\n" +bindkey -s 'l' 'Q l\n' +#bindkey -s 'L' 'Q la\n' -bindkey -s " " "\\\\ " +bindkey -s ' ' '\\\\ ' -bindkey -s "g" "Q git-status\n" -bindkey -s "G" "Q git-repack\n" +bindkey -s 'g' 'Q git-status\n' +bindkey -s 'G' 'Q git-repack\n' -bindkey -s "X" "Q exec zsh\n" +bindkey -s 'X' 'Q exec zsh\n' -- cgit v1.2.3 From 15b62e4841e3c36a7ac96f1d4ade8757cca0acda Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Mon, 17 Mar 2008 15:10:54 +0100 Subject: Colors stored in an array instead of multiples annoying envvars. --- 01_Functions.zsh | 8 ++--- 11_Prompts.zsh | 91 +++++++++++++++++++++++++++++--------------------------- 2 files changed, 51 insertions(+), 48 deletions(-) diff --git a/01_Functions.zsh b/01_Functions.zsh index 58a4ba5..3d1221d 100644 --- a/01_Functions.zsh +++ b/01_Functions.zsh @@ -87,13 +87,13 @@ get_git_status () if [ "$(git-rev-parse --git-dir)" == "." ] then - my_git_status="$COLOR_GIT_MANAGMENT" + my_git_status="$git_colors[managment_folder]" elif [ "$(git-diff --cached 2>&- | grep '^diff ')" != "" ] ; then - my_git_status="$COLOR_GIT_CACHED" + my_git_status="$git_colors[cached]" elif [ "$(git-ls-files -m 2>&-)" != "" ] ; then - my_git_status="$COLOR_GIT_NOT_UP_TO_DATE" + my_git_status="$git_colors[not_up_to_date]" else - my_git_status="$COLOR_GIT_UP_TO_DATE" + my_git_status="$git_colors[up_to_date]" fi echo $my_git_status diff --git a/11_Prompts.zsh b/11_Prompts.zsh index 0baea0e..babb165 100644 --- a/11_Prompts.zsh +++ b/11_Prompts.zsh @@ -21,17 +21,19 @@ # # I'm storing the resulting dominant color in $GENERIC +typeset -A prompt_colors git_colors mail_colors + PS1_ROOT=${PS1_ROOT:-$color[red]} PS1_USER=${PS1_USER:-$color[blue]} PS1_USER_SSH=${PS1_USER_SSH:-$color[magenta]} -GENERIC=`print -Pn "%(! $PS1_ROOT $PS1_USER)"` +prompt_colors[generic]=`print -Pn "%(! $PS1_ROOT $PS1_USER)"` normal_user && if ( [ "$SSH_TTY" != "" ] ) then # This allows us to easily distinguish shells # which really are on the local machine or not. # That's so good, use it ! :-) - GENERIC=${PS1_USER_SSH:-$GENERIC} + prompt_colors[generic]=${PS1_USER_SSH:-$prompt_colors[generic]} fi c_=[ @@ -41,39 +43,40 @@ _C="$_c%}" set_prompt_colors () { - local generic=${1:-$GENERIC} + prompt_colors[generic]=${1:-$prompt_colors[generic]} ## Les couleurs !! ## - COLOR_PATH="$color[reset];$generic;$color[bold]" # pwd - #COLOR_TERM="$color[reset];$generic" # tty - COLOR_USER="$color[reset];$generic" # login - COLOR_HOST="$color[reset];$generic" # hostname - #COLOR_HIST="$color[reset]" # history number - COLOR_AROB="$color[reset];1;%(! $color[bold]; )$generic" # @ - COLOR_DIES="$color[reset];$generic" # the bottom-end of the prompt - COLOR_DOUBLEDOT="$color[reset];" # separates pwd from git-branch - #COLOR_PAREN="$color[reset];$color[cyan]" # parenthesis (around tty) - COLOR_MAIL="$color[reset];$color[yellow];$color[bold]" # mail received - COLOR_LISTES="$color[reset];$color[red];$color[bold]" # less important mail received - COLOR_BAR="$color[reset];$generic;$color[bold]" # horizontal bar - COLOR_BRACES=$COLOR_BAR # braces (around date) - COLOR_ERRR="$color[bold];$color[yellow]" # error code - COLOR_DATE="$color[reset];$generic" # full date - - COLOR_CMD="$color[reset]" # command prompt - COLOR_EXEC="$color[reset]" # command output - - COLOR_BRANCH_OR_REV="$color[reset];$generic" # up-to-date - COLOR_NOT_UP_TO_DATE="$color[reset];$color[green];$color[bold]" # not up to date - COLOR_TO_BE_COMMITED="$color[reset];$color[yellow];$color[bold]" # changes in cache - - COLOR_GIT_MANAGMENT="$color[reset];$color[red];$color[bold]" # .git/... folder browsing - COLOR_GIT_CACHED="$color[reset];$COLOR_TO_BE_COMMITED" # git changes in cache - COLOR_GIT_NOT_UP_TO_DATE="$color[reset];$COLOR_NOT_UP_TO_DATE" # git changes in working tree - COLOR_GIT_UP_TO_DATE="$color[reset];$generic" # git up-to-date + prompt_colors[path]="$color[none];$prompt_colors[generic];$color[bold]" # pwd + #prompt_colors[term]="$color[none];$prompt_colors[generic]" # tty + prompt_colors[user]="$color[none];$prompt_colors[generic]" # login + prompt_colors[host]="$color[none];$prompt_colors[generic]" # hostname + #prompt_colors[hist]="$color[none]" # history number + prompt_colors[arob]="$color[none];$color[bold];$prompt_colors[generic]" # @ + prompt_colors[dies]="$color[none];$prompt_colors[generic]" # the bottom-end of the prompt + prompt_colors[doubledot]="$color[none];" # separates pwd from git-branch + #prompt_colors[paren]="$color[none];$color[cyan]" # parenthesis (around tty) + prompt_colors[bar]="$color[none];$prompt_colors[generic];$color[bold]" # horizontal bar + prompt_colors[braces]=$prompt_colors[bar] # braces (around date) + prompt_colors[error]="$color[bold];$color[yellow]" # error code + prompt_colors[date]="$color[none];$prompt_colors[generic]" # full date + + prompt_colors[cmd]="$color[none]" # command prompt + prompt_colors[exec]="$color[none]" # command output + + mail_colors[unread]="$color[none];$color[yellow];$color[bold]" # mail received + mail_colors[listes]="$color[none];$color[red];$color[bold]" # less important mail received + + prompt_colors[up_to_date]="$color[none];$prompt_colors[generic]" # up-to-date + prompt_colors[not_up_to_date]="$color[none];$color[green];$color[bold]" # not up to date + prompt_colors[to_be_commited]="$color[none];$color[yellow];$color[bold]" # changes in cache + + git_colors[managment_folder]="$color[none];$color[red];$color[bold]" # .git/... folder browsing + git_colors[cached]="$prompt_colors[to_be_commited]" # git changes in cache + git_colors[not_up_to_date]="$prompt_colors[not_up_to_date]" # git changes in working tree + git_colors[up_to_date]="$prompt_colors[up_to_date]" # git up-to-date } -set_prompt_colors $GENERIC +set_prompt_colors $prompt_colors[generic] ## Prompts # @@ -90,7 +93,7 @@ set_prompt_colors $GENERIC preexec () { term_title " ··· $(echo $1 | tr ' \n' ' ;' | sed 's/%/%%/g;s/\\/\\\\/g')" - print -Pn "$C_$COLOR_EXEC$_C" + print -Pn "$C_$prompt_colors[exec]$_C" } expand_text() @@ -110,11 +113,11 @@ new_precmd() # [4] post-string # typeset -A ERROR DATE MAILS LOGIN HOST CWD GITINFO SVNINFO PRECMD - ERROR[color] = $COLOR_ERROR + ERROR[color] = $prompt_colors[error] ERROR[string] = "%(?;;%?)" ERROR[pre] = "-" ERROR[post] = - ERROR[size] = ${#$(print -Pn $ERROR["pre"]$ERROR["string"]$ERROR["post"])} + ERROR[size] = ${#$(print -Pn $ERROR[pre]$ERROR[string]$ERROR[post])} } old_precmd() @@ -122,18 +125,18 @@ old_precmd() # Error error=$(print -Pn "%(?;;-%?)") ERRORSIZE=${#error} - ERROR="%(?;;"$C_$COLOR_BAR$_C"-"$C_$COLOR_ERRR$_C"%?)" + ERROR="%(?;;"$C_$prompt_colors[bar]$_C"-"$C_$prompt_colors[error]$_C"%?)" # Flush the term title term_title # Date - DATE=$C_$COLOR_BRACES$_C"[ "$C_$COLOR_DATE$_C"%D{%a-%d-%b-%Y %H:%M:%S}"$C_$COLOR_BRACES$_C" ]"$C_$COLOR_BAR$_C"-" + DATE=$C_$prompt_colors[braces]$_C"[ "$C_$prompt_colors[date]$_C"%D{%a-%d-%b-%Y %H:%M:%S}"$C_$prompt_colors[braces]$_C" ]"$C_$prompt_colors[bar]$_C"-" DATEEXPAND=$(expand_text "$DATE") DATESIZE=${#DATEEXPAND} # Mailcheck - MAILSTAT=$(eval echo "`[ -s ~/.procmail/procmail.log ] && < ~/.procmail/procmail.log awk 'BEGIN {RS="From" ; HAM=-1 ; LISTES=0 } !/JUNK/ { HAM++ } /Listes|Newsletters|Notifications/ { LISTES++ } END { if ((HAM - LISTES) > 0) { print "$C_$COLOR_BAR$_C""-""$C_$COLOR_MAIL$_C""@" } else if (LISTES > 0) { print "$C_$COLOR_BAR$_C""-""$C_$COLOR_LISTES$_C""@" } }'`") + MAILSTAT=$(eval echo "`[ -s ~/.procmail/procmail.log ] && < ~/.procmail/procmail.log awk 'BEGIN {RS="From" ; HAM=-1 ; LISTES=0 } !/JUNK/ { HAM++ } /Listes|Newsletters|Notifications/ { LISTES++ } END { if ((HAM - LISTES) > 0) { print "$C_$prompt_colors[bar]$_C""-""$C_$mail_colors[unread]$_C""@" } else if (LISTES > 0) { print "$C_$prompt_colors[bar]$_C""-""$C_$mail_colors[listes]$_C""@" } }'`") MAILSTATEXPAND=$(expand_text "$MAILSTAT") MAILSTATSIZE=${#MAILSTATEXPAND} @@ -188,15 +191,15 @@ old_precmd() # then we reduce the path until it reaches the last path element, spaceleft=$(($spaceleft - $GITBRANCHSIZE)) [ $spaceleft -lt $minimalpathsize ] && spaceleft=$minimalpathsize - GITBRANCH=${GITBRANCH:+$C_$COLOR_DOUBLEDOT$_C:$C_"$(get_git_status)"$_C$GITBRANCH} - CURDIR="$C_$COLOR_PATH$_C%`echo $spaceleft`<..<"$MY_PATH"%<<$C_$color[reset]$_C" + GITBRANCH=${GITBRANCH:+$C_$prompt_colors[doubledot]$_C:$C_"$(get_git_status)"$_C$GITBRANCH} + CURDIR="$C_$prompt_colors[path]$_C%`echo $spaceleft`<..<"$MY_PATH"%<<$C_$color[none]$_C" ## Le prompt le plus magnifique du monde, et c'est le mien ! # Affiche l'user, l'host, le tty et le pwd. Rien que ça... # Note que pour le pwd, on n'affiche que les 4 derniers dossiers pour éviter # de pourrir le fenêtre de terminal avec un prompt à rallonge. - PS1="$MAILSTAT""$ERROR"$C_$COLOR_BAR$_C"$HBAR""$DATE -"$C_$COLOR_USER$_C"%n"$C_$COLOR_AROB$_C"@"$C_$COLOR_HOST$_C"%m $CURDIR$GITBRANCH "$C_$COLOR_DIES$_C"%#"$C_$COLOR_CMD$_C" " + PS1="$MAILSTAT""$ERROR"$C_$prompt_colors[bar]$_C"$HBAR""$DATE +"$C_$prompt_colors[user]$_C"%n"$C_$prompt_colors[arob]$_C"@"$C_$prompt_colors[host]$_C"%m $CURDIR$GITBRANCH "$C_$prompt_colors[dies]$_C"%#"$C_$prompt_colors[cmd]$_C" " } @@ -213,7 +216,7 @@ chpwd() # Prompt level 2 -PS2="$C_$color[yellow];$color[bold]$_C%_$C_$color[reset];$color[cyan];$color[bold]$_C>$C_$color[reset]$_C " +PS2="$C_$color[yellow];$color[bold]$_C%_$C_$color[none];$color[cyan];$color[bold]$_C>$C_$color[none]$_C " # Prompt level 3 PS3="?# " @@ -222,8 +225,8 @@ PS3="?# " PS4="+%N:%i> " # Prompt de droite, pour l'heure et le code d'erreur de la dernière commande -#RPS1="%(?;;"$C_$COLOR_ERRR$_C"%?"$C_$color[reset]$_C")" +#RPS1="%(?;;"$C_$prompt_colors[error]$_C"%?"$C_$color[none]$_C")" # Ultime : prompt de correction :-) -SPROMPT="zsh: $C_$color[blue]$_C%B'%R'%b$C_$color[reset]$_C ? Vous ne vouliez pas plutôt $C_$color[magenta]$_C%B'%r'%b$C_$color[reset]$_C ? [%BN%byae] " +SPROMPT="zsh: $C_$color[blue]$_C%B'%R'%b$C_$color[none]$_C ? Vous ne vouliez pas plutôt $C_$color[magenta]$_C%B'%r'%b$C_$color[none]$_C ? [%BN%byae] " -- cgit v1.2.3 From cdb83832e1084ec9416110e78ff23171a4c0cbe0 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Mon, 17 Mar 2008 15:11:35 +0100 Subject: svn tracking. --- 11_Prompts.zsh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/11_Prompts.zsh b/11_Prompts.zsh index babb165..3c490fe 100644 --- a/11_Prompts.zsh +++ b/11_Prompts.zsh @@ -153,6 +153,18 @@ old_precmd() ## Second line of prompt : don't let the path garbage the entire line ## + # get svn status + # + SVNREV=$(LC_ALL=C svn info 2>&- $PWD | awk '/^Revision: / {print $2}') + SVNREVSIZE=${#${SVNREV:+:r$SVNREV}} + if [ "$SVNREV" != "" ] + then + SVNSTATUS="$(svn status 2>&-)" + SVNSTATUS=${SVNSTATUS:+$prompt_colors[not_up_to_date]} + SVNSTATUS=${SVNSTATUS:-$prompt_colors[up_to_date]} + fi + SVNREV=${SVNREV:+$C_$prompt_colors[doubledot]$_C:$C_$SVNSTATUS$_C"r"$SVNREV} + # get git status # GITBRANCH=$(get_git_branch) @@ -199,7 +211,7 @@ old_precmd() # Note que pour le pwd, on n'affiche que les 4 derniers dossiers pour éviter # de pourrir le fenêtre de terminal avec un prompt à rallonge. PS1="$MAILSTAT""$ERROR"$C_$prompt_colors[bar]$_C"$HBAR""$DATE -"$C_$prompt_colors[user]$_C"%n"$C_$prompt_colors[arob]$_C"@"$C_$prompt_colors[host]$_C"%m $CURDIR$GITBRANCH "$C_$prompt_colors[dies]$_C"%#"$C_$prompt_colors[cmd]$_C" " +"$C_$prompt_colors[user]$_C"%n"$C_$prompt_colors[arob]$_C"@"$C_$prompt_colors[host]$_C"%m $CURDIR$SVNREV$GITBRANCH "$C_$prompt_colors[dies]$_C"%#"$C_$prompt_colors[cmd]$_C" " } -- cgit v1.2.3 From 17d84509ebeab4c76cafb06e59cec4c35f3d2ec9 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Mon, 17 Mar 2008 15:41:43 +0100 Subject: Binding to launch an svn status. --- user:hugues/KeyBindings.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/user:hugues/KeyBindings.zsh b/user:hugues/KeyBindings.zsh index 2fdb66e..02c114f 100644 --- a/user:hugues/KeyBindings.zsh +++ b/user:hugues/KeyBindings.zsh @@ -222,4 +222,6 @@ bindkey -s ' ' '\\\\ ' bindkey -s 'g' 'Q git-status\n' bindkey -s 'G' 'Q git-repack\n' +bindkey -s 'S' 'Q svn status\n' + bindkey -s 'X' 'Q exec zsh\n' -- cgit v1.2.3 From 1a53a4ba1d9581271adb09841baee5423df55ad9 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Thu, 20 Mar 2008 09:42:36 +0100 Subject: Colors defs moved from Prompts.zsh to Colors.zsh --- 11_Colors.zsh | 82 +++++++++++++++++++ 11_Prompts.zsh | 244 --------------------------------------------------------- 12_Prompts.zsh | 176 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 258 insertions(+), 244 deletions(-) create mode 100644 11_Colors.zsh delete mode 100644 11_Prompts.zsh create mode 100644 12_Prompts.zsh diff --git a/11_Colors.zsh b/11_Colors.zsh new file mode 100644 index 0000000..fa1522c --- /dev/null +++ b/11_Colors.zsh @@ -0,0 +1,82 @@ +## +## Part of configuration files for Zsh 4 +## by Hugues Hiegel +## +## NO WARRANTY PROVIDED, USE AT YOUR OWN RISKS +## +## You are encouraged to use, modify, and redistribute +## these files with or without this notice. +## + +c_=[ +_c=m +C_="%{$c_" +_C="$_c%}" + +typeset -A prompt_colors git_colors mail_colors + +# I hate kik00l0l colorized prompts, so I'm using a way to +# give a dominant color for each part of the prompt, each of +# these remain still configurable one by one. +# Take a look to set_prompt_colors for these colorizations. +# +# To set the dominant color I'm using this : +# +# - PS1_ROOT when we are root +# - PS1_USER for normal usage +# - PS1_USER_SSH when we are connected through SSH +# +# I'm storing the resulting dominant color in $prompt_colors[generic] + +PS1_ROOT=${PS1_ROOT:-$color[red]} +PS1_USER=${PS1_USER:-$color[blue]} +PS1_USER_SSH=${PS1_USER_SSH:-$color[magenta]} +prompt_colors[generic]=`print -Pn "%(! $PS1_ROOT $PS1_USER)"` + +normal_user && if ( [ "$SSH_TTY" != "" ] ) +then + # This allows us to easily distinguish shells + # which really are on the local machine or not. + # That's so good, use it ! :-) + prompt_colors[generic]=${PS1_USER_SSH:-$prompt_colors[generic]} +fi + +# +# This func is intended to give a quick way to set the colors for the +# prompt inside a running zsh-session +# +set_prompt_colors () +{ + prompt_colors[generic]=${1:-$prompt_colors[generic]} + + prompt_colors[path]="$color[none];$prompt_colors[generic];$color[bold]" # pwd + #prompt_colors[term]="$color[none];$prompt_colors[generic]" # tty + prompt_colors[user]="$color[none];$prompt_colors[generic]" # login + prompt_colors[host]="$color[none];$prompt_colors[generic]" # hostname + #prompt_colors[hist]="$color[none]" # history number + prompt_colors[arob]="$color[none];$color[bold];$prompt_colors[generic]" # @ + prompt_colors[dies]="$color[none];$prompt_colors[generic]" # the bottom-end of the prompt + prompt_colors[doubledot]="$color[none];" # separates pwd from git-branch + #prompt_colors[paren]="$color[none];$color[cyan]" # parenthesis (around tty) + prompt_colors[bar]="$color[none];$prompt_colors[generic];$color[bold]" # horizontal bar + prompt_colors[braces]=$prompt_colors[bar] # braces (around date) + prompt_colors[error]="$color[bold];$color[yellow]" # error code + prompt_colors[date]="$color[none];$prompt_colors[generic]" # full date + + prompt_colors[cmd]="$color[none]" # command prompt + prompt_colors[exec]="$color[none]" # command output + + mail_colors[unread]="$color[none];$color[yellow];$color[bold]" # mail received + mail_colors[listes]="$color[none];$color[red];$color[bold]" # less important mail received + + prompt_colors[up_to_date]="$color[none];$prompt_colors[generic]" # up-to-date + prompt_colors[not_up_to_date]="$color[none];$color[green];$color[bold]" # not up to date + prompt_colors[to_be_commited]="$color[none];$color[yellow];$color[bold]" # changes in cache + + git_colors[managment_folder]="$color[none];$color[red];$color[bold]" # .git/... folder browsing + git_colors[cached]="$prompt_colors[to_be_commited]" # git changes in cache + git_colors[not_up_to_date]="$prompt_colors[not_up_to_date]" # git changes in working tree + git_colors[up_to_date]="$prompt_colors[up_to_date]" # git up-to-date +} + +set_prompt_colors diff --git a/11_Prompts.zsh b/11_Prompts.zsh deleted file mode 100644 index 3c490fe..0000000 --- a/11_Prompts.zsh +++ /dev/null @@ -1,244 +0,0 @@ -## -## Part of configuration files for Zsh 4 -## by Hugues Hiegel -## -## NO WARRANTY PROVIDED, USE AT YOUR OWN RISKS -## -## You are encouraged to use, modify, and redistribute -## these files with or without this notice. -## - -# I hate kik00l0l colorized prompts, so I'm using a way to -# give a dominant color for each part of the prompt, each of -# these remain still configurable one by one. -# Take a look to set_prompt_colors for these colorizations. -# -# To set the dominant color I'm using this : -# -# - PS1_ROOT when we are root -# - PS1_USER for normal usage -# - PS1_USER_SSH when we are connected through SSH -# -# I'm storing the resulting dominant color in $GENERIC - -typeset -A prompt_colors git_colors mail_colors - -PS1_ROOT=${PS1_ROOT:-$color[red]} -PS1_USER=${PS1_USER:-$color[blue]} -PS1_USER_SSH=${PS1_USER_SSH:-$color[magenta]} -prompt_colors[generic]=`print -Pn "%(! $PS1_ROOT $PS1_USER)"` - -normal_user && if ( [ "$SSH_TTY" != "" ] ) -then - # This allows us to easily distinguish shells - # which really are on the local machine or not. - # That's so good, use it ! :-) - prompt_colors[generic]=${PS1_USER_SSH:-$prompt_colors[generic]} -fi - -c_=[ -_c=m -C_="%{$c_" -_C="$_c%}" - -set_prompt_colors () -{ - prompt_colors[generic]=${1:-$prompt_colors[generic]} - - ## Les couleurs !! ## - prompt_colors[path]="$color[none];$prompt_colors[generic];$color[bold]" # pwd - #prompt_colors[term]="$color[none];$prompt_colors[generic]" # tty - prompt_colors[user]="$color[none];$prompt_colors[generic]" # login - prompt_colors[host]="$color[none];$prompt_colors[generic]" # hostname - #prompt_colors[hist]="$color[none]" # history number - prompt_colors[arob]="$color[none];$color[bold];$prompt_colors[generic]" # @ - prompt_colors[dies]="$color[none];$prompt_colors[generic]" # the bottom-end of the prompt - prompt_colors[doubledot]="$color[none];" # separates pwd from git-branch - #prompt_colors[paren]="$color[none];$color[cyan]" # parenthesis (around tty) - prompt_colors[bar]="$color[none];$prompt_colors[generic];$color[bold]" # horizontal bar - prompt_colors[braces]=$prompt_colors[bar] # braces (around date) - prompt_colors[error]="$color[bold];$color[yellow]" # error code - prompt_colors[date]="$color[none];$prompt_colors[generic]" # full date - - prompt_colors[cmd]="$color[none]" # command prompt - prompt_colors[exec]="$color[none]" # command output - - mail_colors[unread]="$color[none];$color[yellow];$color[bold]" # mail received - mail_colors[listes]="$color[none];$color[red];$color[bold]" # less important mail received - - prompt_colors[up_to_date]="$color[none];$prompt_colors[generic]" # up-to-date - prompt_colors[not_up_to_date]="$color[none];$color[green];$color[bold]" # not up to date - prompt_colors[to_be_commited]="$color[none];$color[yellow];$color[bold]" # changes in cache - - git_colors[managment_folder]="$color[none];$color[red];$color[bold]" # .git/... folder browsing - git_colors[cached]="$prompt_colors[to_be_commited]" # git changes in cache - git_colors[not_up_to_date]="$prompt_colors[not_up_to_date]" # git changes in working tree - git_colors[up_to_date]="$prompt_colors[up_to_date]" # git up-to-date -} - -set_prompt_colors $prompt_colors[generic] - -## Prompts -# -# man zshmisc(1) -# - -## Automagic funcs -# -# chpwd : changement de répertoire -# preexec : avant d'exécuter une commande -# precmd : avant d'afficher le prompt -# - -preexec () -{ - term_title " ··· $(echo $1 | tr ' \n' ' ;' | sed 's/%/%%/g;s/\\/\\\\/g')" - print -Pn "$C_$prompt_colors[exec]$_C" -} - -expand_text() -{ - # strips the %{...%} - print -Pn -- "$(echo $@ | sed 's/%{[^(%})]*%}//g')" -} - -new_precmd() -{ - # - # Arrays - # [0] prompt-style string - # [1] total size - # [2] color - # [3] pre-string - # [4] post-string - # - typeset -A ERROR DATE MAILS LOGIN HOST CWD GITINFO SVNINFO PRECMD - ERROR[color] = $prompt_colors[error] - ERROR[string] = "%(?;;%?)" - ERROR[pre] = "-" - ERROR[post] = - ERROR[size] = ${#$(print -Pn $ERROR[pre]$ERROR[string]$ERROR[post])} -} - -old_precmd() -{ - # Error - error=$(print -Pn "%(?;;-%?)") - ERRORSIZE=${#error} - ERROR="%(?;;"$C_$prompt_colors[bar]$_C"-"$C_$prompt_colors[error]$_C"%?)" - - # Flush the term title - term_title - - # Date - DATE=$C_$prompt_colors[braces]$_C"[ "$C_$prompt_colors[date]$_C"%D{%a-%d-%b-%Y %H:%M:%S}"$C_$prompt_colors[braces]$_C" ]"$C_$prompt_colors[bar]$_C"-" - DATEEXPAND=$(expand_text "$DATE") - DATESIZE=${#DATEEXPAND} - - # Mailcheck - MAILSTAT=$(eval echo "`[ -s ~/.procmail/procmail.log ] && < ~/.procmail/procmail.log awk 'BEGIN {RS="From" ; HAM=-1 ; LISTES=0 } !/JUNK/ { HAM++ } /Listes|Newsletters|Notifications/ { LISTES++ } END { if ((HAM - LISTES) > 0) { print "$C_$prompt_colors[bar]$_C""-""$C_$mail_colors[unread]$_C""@" } else if (LISTES > 0) { print "$C_$prompt_colors[bar]$_C""-""$C_$mail_colors[listes]$_C""@" } }'`") - MAILSTATEXPAND=$(expand_text "$MAILSTAT") - MAILSTATSIZE=${#MAILSTATEXPAND} - - # First line of prompt, calculation of the remaining place - spaceleft=$((1 + $COLUMNS - $ERRORSIZE - $MAILSTATSIZE - $DATESIZE)) - - unset HBAR - for h in {1..$(($spaceleft - 1))} - do - HBAR=$HBAR- - done - - ## - ## Second line of prompt : don't let the path garbage the entire line - ## - - # get svn status - # - SVNREV=$(LC_ALL=C svn info 2>&- $PWD | awk '/^Revision: / {print $2}') - SVNREVSIZE=${#${SVNREV:+:r$SVNREV}} - if [ "$SVNREV" != "" ] - then - SVNSTATUS="$(svn status 2>&-)" - SVNSTATUS=${SVNSTATUS:+$prompt_colors[not_up_to_date]} - SVNSTATUS=${SVNSTATUS:-$prompt_colors[up_to_date]} - fi - SVNREV=${SVNREV:+$C_$prompt_colors[doubledot]$_C:$C_$SVNSTATUS$_C"r"$SVNREV} - - # get git status - # - GITBRANCH=$(get_git_branch) - GITBRANCHSIZE=${#GITBRANCH} - [ $GITBRANCHSIZE -gt 0 ] && GITBRANCHSIZE=$(($GITBRANCHSIZE)) - - MY_PATH="%(!.%d.%~)" - PATHSIZE=$(print -Pn $MY_PATH) - PATHSIZE=${#PATHSIZE} - spaceleft=`print -Pn "%n@%m $ ls -laCdtrux $(expand_text "$DATE")"` - spaceleft=$(($COLUMNS - ${#spaceleft})) - #minimalpathsize=`print -Pn "../%1~"` - #minimalpathsize=${#minimalpathsize} - minimalpathsize=10 - minimalgitsize=10 # git-abbrev-commit-ish... - if [ $GITBRANCHSIZE -gt 0 ] - then - if [ $spaceleft -lt $(( $PATHSIZE + $GITBRANCHSIZE )) ] - then - local unbreakablegittail - # reduce the git-branch until it is shrinked to $minimalgitsize characters max. - - if [ $GITBRANCH[-1] = ")" ] - then - unbreakablegittail=${${(M)GITBRANCH%\~*}} - [ "$unbreakablegittail" = "" -a $GITBRANCHSIZE -gt $minimalgitsize ] && unbreakablegittail=")" - fi - if [ $GITBRANCHSIZE -gt $minimalgitsize ] - then - GITBRANCHSIZE=$(( $spaceleft - $PATHSIZE )) - [ $GITBRANCHSIZE -lt $minimalgitsize ] && GITBRANCHSIZE=$minimalgitsize - fi - GITBRANCH=`print -Pn "%"$(($GITBRANCHSIZE - ${#unbreakablegittail}))">..>"${GITBRANCH%\~*}${unbreakablegittail:+"%"${#unbreakablegittail}"<<"$GITBRANCH}` - fi - fi - # then we reduce the path until it reaches the last path element, - spaceleft=$(($spaceleft - $GITBRANCHSIZE)) - [ $spaceleft -lt $minimalpathsize ] && spaceleft=$minimalpathsize - GITBRANCH=${GITBRANCH:+$C_$prompt_colors[doubledot]$_C:$C_"$(get_git_status)"$_C$GITBRANCH} - CURDIR="$C_$prompt_colors[path]$_C%`echo $spaceleft`<..<"$MY_PATH"%<<$C_$color[none]$_C" - -## Le prompt le plus magnifique du monde, et c'est le mien ! -# Affiche l'user, l'host, le tty et le pwd. Rien que ça... -# Note que pour le pwd, on n'affiche que les 4 derniers dossiers pour éviter -# de pourrir le fenêtre de terminal avec un prompt à rallonge. - PS1="$MAILSTAT""$ERROR"$C_$prompt_colors[bar]$_C"$HBAR""$DATE -"$C_$prompt_colors[user]$_C"%n"$C_$prompt_colors[arob]$_C"@"$C_$prompt_colors[host]$_C"%m $CURDIR$SVNREV$GITBRANCH "$C_$prompt_colors[dies]$_C"%#"$C_$prompt_colors[cmd]$_C" " - - -} - -precmd() -{ - old_precmd -} - -chpwd() -{ - which todo > /dev/null 2>&1 && todo -} - - -# Prompt level 2 -PS2="$C_$color[yellow];$color[bold]$_C%_$C_$color[none];$color[cyan];$color[bold]$_C>$C_$color[none]$_C " - -# Prompt level 3 -PS3="?# " - -# Prompt level 4 -PS4="+%N:%i> " - -# Prompt de droite, pour l'heure et le code d'erreur de la dernière commande -#RPS1="%(?;;"$C_$prompt_colors[error]$_C"%?"$C_$color[none]$_C")" - -# Ultime : prompt de correction :-) -SPROMPT="zsh: $C_$color[blue]$_C%B'%R'%b$C_$color[none]$_C ? Vous ne vouliez pas plutôt $C_$color[magenta]$_C%B'%r'%b$C_$color[none]$_C ? [%BN%byae] " - diff --git a/12_Prompts.zsh b/12_Prompts.zsh new file mode 100644 index 0000000..d9ae9fa --- /dev/null +++ b/12_Prompts.zsh @@ -0,0 +1,176 @@ +## +## Part of configuration files for Zsh 4 +## by Hugues Hiegel +## +## NO WARRANTY PROVIDED, USE AT YOUR OWN RISKS +## +## You are encouraged to use, modify, and redistribute +## these files with or without this notice. +## + +set_prompt_colors $prompt_colors[generic] + +## Prompts +# +# man zshmisc(1) +# + +## Automagic funcs +# +# chpwd : changement de répertoire +# preexec : avant d'exécuter une commande +# precmd : avant d'afficher le prompt +# + +preexec () +{ + term_title " ··· $(echo $1 | tr ' \n' ' ;' | sed 's/%/%%/g;s/\\/\\\\/g')" + print -Pn "$C_$prompt_colors[exec]$_C" +} + +expand_text() +{ + # strips the %{...%} + print -Pn -- "$(echo $@ | sed 's/%{[^(%})]*%}//g')" +} + +new_precmd() +{ + # + # Arrays + # [0] prompt-style string + # [1] total size + # [2] color + # [3] pre-string + # [4] post-string + # + typeset -A ERROR DATE MAILS LOGIN HOST CWD GITINFO SVNINFO PRECMD + ERROR[color] = $prompt_colors[error] + ERROR[string] = "%(?;;%?)" + ERROR[pre] = "-" + ERROR[post] = + ERROR[size] = ${#$(print -Pn $ERROR[pre]$ERROR[string]$ERROR[post])} +} + +old_precmd() +{ + # Error + error=$(print -Pn "%(?;;-%?)") + ERRORSIZE=${#error} + ERROR="%(?;;"$C_$prompt_colors[bar]$_C"-"$C_$prompt_colors[error]$_C"%?)" + + # Flush the term title + term_title + + # Date + DATE=$C_$prompt_colors[braces]$_C"[ "$C_$prompt_colors[date]$_C"%D{%a-%d-%b-%Y %H:%M:%S}"$C_$prompt_colors[braces]$_C" ]"$C_$prompt_colors[bar]$_C"-" + DATEEXPAND=$(expand_text "$DATE") + DATESIZE=${#DATEEXPAND} + + # Mailcheck + MAILSTAT=$(eval echo "`[ -s ~/.procmail/procmail.log ] && < ~/.procmail/procmail.log awk 'BEGIN {RS="From" ; HAM=-1 ; LISTES=0 } !/JUNK/ { HAM++ } /Listes|Newsletters|Notifications/ { LISTES++ } END { if ((HAM - LISTES) > 0) { print "$C_$prompt_colors[bar]$_C""-""$C_$mail_colors[unread]$_C""@" } else if (LISTES > 0) { print "$C_$prompt_colors[bar]$_C""-""$C_$mail_colors[listes]$_C""@" } }'`") + MAILSTATEXPAND=$(expand_text "$MAILSTAT") + MAILSTATSIZE=${#MAILSTATEXPAND} + + # First line of prompt, calculation of the remaining place + spaceleft=$((1 + $COLUMNS - $ERRORSIZE - $MAILSTATSIZE - $DATESIZE)) + + unset HBAR + for h in {1..$(($spaceleft - 1))} + do + HBAR=$HBAR- + done + + ## + ## Second line of prompt : don't let the path garbage the entire line + ## + + # get svn status + # + SVNREV=$(LC_ALL=C svn info 2>&- $PWD | awk '/^Revision: / {print $2}') + SVNREVSIZE=${#${SVNREV:+:r$SVNREV}} + if [ "$SVNREV" != "" ] + then + SVNSTATUS="$(svn status 2>&-)" + SVNSTATUS=${SVNSTATUS:+$prompt_colors[not_up_to_date]} + SVNSTATUS=${SVNSTATUS:-$prompt_colors[up_to_date]} + fi + SVNREV=${SVNREV:+$C_$prompt_colors[doubledot]$_C:$C_$SVNSTATUS$_C"r"$SVNREV} + + # get git status + # + GITBRANCH=$(get_git_branch) + GITBRANCHSIZE=${#GITBRANCH} + [ $GITBRANCHSIZE -gt 0 ] && GITBRANCHSIZE=$(($GITBRANCHSIZE)) + + MY_PATH="%(!.%d.%~)" + PATHSIZE=$(print -Pn $MY_PATH) + PATHSIZE=${#PATHSIZE} + spaceleft=`print -Pn "%n@%m $ ls -laCdtrux $(expand_text "$DATE")"` + spaceleft=$(($COLUMNS - ${#spaceleft})) + #minimalpathsize=`print -Pn "../%1~"` + #minimalpathsize=${#minimalpathsize} + minimalpathsize=10 + minimalgitsize=10 # git-abbrev-commit-ish... + if [ $GITBRANCHSIZE -gt 0 ] + then + if [ $spaceleft -lt $(( $PATHSIZE + $GITBRANCHSIZE )) ] + then + local unbreakablegittail + # reduce the git-branch until it is shrinked to $minimalgitsize characters max. + + if [ $GITBRANCH[-1] = ")" ] + then + unbreakablegittail=${${(M)GITBRANCH%\~*}} + [ "$unbreakablegittail" = "" -a $GITBRANCHSIZE -gt $minimalgitsize ] && unbreakablegittail=")" + fi + if [ $GITBRANCHSIZE -gt $minimalgitsize ] + then + GITBRANCHSIZE=$(( $spaceleft - $PATHSIZE )) + [ $GITBRANCHSIZE -lt $minimalgitsize ] && GITBRANCHSIZE=$minimalgitsize + fi + GITBRANCH=`print -Pn "%"$(($GITBRANCHSIZE - ${#unbreakablegittail}))">..>"${GITBRANCH%\~*}${unbreakablegittail:+"%"${#unbreakablegittail}"<<"$GITBRANCH}` + fi + fi + # then we reduce the path until it reaches the last path element, + spaceleft=$(($spaceleft - $GITBRANCHSIZE)) + [ $spaceleft -lt $minimalpathsize ] && spaceleft=$minimalpathsize + GITBRANCH=${GITBRANCH:+$C_$prompt_colors[doubledot]$_C:$C_"$(get_git_status)"$_C$GITBRANCH} + CURDIR="$C_$prompt_colors[path]$_C%`echo $spaceleft`<..<"$MY_PATH"%<<$C_$color[none]$_C" + +## Le prompt le plus magnifique du monde, et c'est le mien ! +# Affiche l'user, l'host, le tty et le pwd. Rien que ça... +# Note que pour le pwd, on n'affiche que les 4 derniers dossiers pour éviter +# de pourrir le fenêtre de terminal avec un prompt à rallonge. + PS1="$MAILSTAT""$ERROR"$C_$prompt_colors[bar]$_C"$HBAR""$DATE +"$C_$prompt_colors[user]$_C"%n"$C_$prompt_colors[arob]$_C"@"$C_$prompt_colors[host]$_C"%m $CURDIR$SVNREV$GITBRANCH "$C_$prompt_colors[dies]$_C"%#"$C_$prompt_colors[cmd]$_C" " + + +} + +precmd() +{ + old_precmd +} + +chpwd() +{ + which todo > /dev/null 2>&1 && todo +} + + +# Prompt level 2 +PS2="$C_$color[yellow];$color[bold]$_C%_$C_$color[none];$color[cyan];$color[bold]$_C>$C_$color[none]$_C " + +# Prompt level 3 +PS3="?# " + +# Prompt level 4 +PS4="+%N:%i> " + +# Prompt de droite, pour l'heure et le code d'erreur de la dernière commande +#RPS1="%(?;;"$C_$prompt_colors[error]$_C"%?"$C_$color[none]$_C")" + +# Ultime : prompt de correction :-) +SPROMPT="zsh: $C_$color[blue]$_C%B'%R'%b$C_$color[none]$_C ? Vous ne vouliez pas plutôt $C_$color[magenta]$_C%B'%r'%b$C_$color[none]$_C ? [%BN%byae] " + -- cgit v1.2.3 From 80d397d87b336fa0dcb573dc41459fc7b5c72977 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Tue, 18 Mar 2008 10:27:20 +0100 Subject: Use of color[none] inside $c_ instead of each named-part. --- 11_Colors.zsh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/11_Colors.zsh b/11_Colors.zsh index fa1522c..bd5ba71 100644 --- a/11_Colors.zsh +++ b/11_Colors.zsh @@ -8,7 +8,7 @@ ## these files with or without this notice. ## -c_=[ +c_='['$color[none]";" _c=m C_="%{$c_" _C="$_c%}" @@ -49,31 +49,31 @@ set_prompt_colors () { prompt_colors[generic]=${1:-$prompt_colors[generic]} - prompt_colors[path]="$color[none];$prompt_colors[generic];$color[bold]" # pwd - #prompt_colors[term]="$color[none];$prompt_colors[generic]" # tty - prompt_colors[user]="$color[none];$prompt_colors[generic]" # login - prompt_colors[host]="$color[none];$prompt_colors[generic]" # hostname + prompt_colors[path]="$prompt_colors[generic];$color[bold]" # pwd + #prompt_colors[term]="$prompt_colors[generic]" # tty + prompt_colors[user]="$prompt_colors[generic]" # login + prompt_colors[host]="$prompt_colors[generic]" # hostname #prompt_colors[hist]="$color[none]" # history number - prompt_colors[arob]="$color[none];$color[bold];$prompt_colors[generic]" # @ - prompt_colors[dies]="$color[none];$prompt_colors[generic]" # the bottom-end of the prompt + prompt_colors[arob]="$color[bold];$prompt_colors[generic]" # @ + prompt_colors[dies]="$prompt_colors[generic]" # the bottom-end of the prompt prompt_colors[doubledot]="$color[none];" # separates pwd from git-branch - #prompt_colors[paren]="$color[none];$color[cyan]" # parenthesis (around tty) - prompt_colors[bar]="$color[none];$prompt_colors[generic];$color[bold]" # horizontal bar - prompt_colors[braces]=$prompt_colors[bar] # braces (around date) + #prompt_colors[paren]="$color[cyan]" # parenthesis (around tty) + prompt_colors[bar]="$prompt_colors[generic];$color[bold]" # horizontal bar + prompt_colors[braces]="$prompt_colors[bar]" # braces (around date) prompt_colors[error]="$color[bold];$color[yellow]" # error code - prompt_colors[date]="$color[none];$prompt_colors[generic]" # full date + prompt_colors[date]="$prompt_colors[generic]" # full date prompt_colors[cmd]="$color[none]" # command prompt prompt_colors[exec]="$color[none]" # command output - mail_colors[unread]="$color[none];$color[yellow];$color[bold]" # mail received - mail_colors[listes]="$color[none];$color[red];$color[bold]" # less important mail received + mail_colors[unread]="$color[yellow];$color[bold]" # mail received + mail_colors[listes]="$color[red];$color[bold]" # less important mail received - prompt_colors[up_to_date]="$color[none];$prompt_colors[generic]" # up-to-date - prompt_colors[not_up_to_date]="$color[none];$color[green];$color[bold]" # not up to date - prompt_colors[to_be_commited]="$color[none];$color[yellow];$color[bold]" # changes in cache + prompt_colors[up_to_date]="$prompt_colors[generic]" # up-to-date + prompt_colors[not_up_to_date]="$color[green];$color[bold]" # not up to date + prompt_colors[to_be_commited]="$color[yellow];$color[bold]" # changes in cache - git_colors[managment_folder]="$color[none];$color[red];$color[bold]" # .git/... folder browsing + git_colors[managment_folder]="$color[red];$color[bold]" # .git/... folder browsing git_colors[cached]="$prompt_colors[to_be_commited]" # git changes in cache git_colors[not_up_to_date]="$prompt_colors[not_up_to_date]" # git changes in working tree git_colors[up_to_date]="$prompt_colors[up_to_date]" # git up-to-date -- cgit v1.2.3 From ff40c760ef2bb633804d1a66679846fcad9ea91a Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Tue, 18 Mar 2008 09:45:08 +0100 Subject: Don't override the 'generic' color. --- 11_Colors.zsh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/11_Colors.zsh b/11_Colors.zsh index bd5ba71..c76fd95 100644 --- a/11_Colors.zsh +++ b/11_Colors.zsh @@ -47,21 +47,22 @@ fi # set_prompt_colors () { - prompt_colors[generic]=${1:-$prompt_colors[generic]} + local my_generic + my_generic=${1:-$prompt_colors[generic]} - prompt_colors[path]="$prompt_colors[generic];$color[bold]" # pwd - #prompt_colors[term]="$prompt_colors[generic]" # tty - prompt_colors[user]="$prompt_colors[generic]" # login - prompt_colors[host]="$prompt_colors[generic]" # hostname + prompt_colors[path]="$my_generic;$color[bold]" # pwd + #prompt_colors[term]="$my_generic" # tty + prompt_colors[user]="$my_generic" # login + prompt_colors[host]="$my_generic" # hostname #prompt_colors[hist]="$color[none]" # history number - prompt_colors[arob]="$color[bold];$prompt_colors[generic]" # @ - prompt_colors[dies]="$prompt_colors[generic]" # the bottom-end of the prompt + prompt_colors[arob]="$color[bold];$my_generic" # @ + prompt_colors[dies]="$my_generic" # the bottom-end of the prompt prompt_colors[doubledot]="$color[none];" # separates pwd from git-branch #prompt_colors[paren]="$color[cyan]" # parenthesis (around tty) - prompt_colors[bar]="$prompt_colors[generic];$color[bold]" # horizontal bar + prompt_colors[bar]="$my_generic;$color[bold]" # horizontal bar prompt_colors[braces]="$prompt_colors[bar]" # braces (around date) prompt_colors[error]="$color[bold];$color[yellow]" # error code - prompt_colors[date]="$prompt_colors[generic]" # full date + prompt_colors[date]="$my_generic" # full date prompt_colors[cmd]="$color[none]" # command prompt prompt_colors[exec]="$color[none]" # command output @@ -69,7 +70,7 @@ set_prompt_colors () mail_colors[unread]="$color[yellow];$color[bold]" # mail received mail_colors[listes]="$color[red];$color[bold]" # less important mail received - prompt_colors[up_to_date]="$prompt_colors[generic]" # up-to-date + prompt_colors[up_to_date]="$my_generic" # up-to-date prompt_colors[not_up_to_date]="$color[green];$color[bold]" # not up to date prompt_colors[to_be_commited]="$color[yellow];$color[bold]" # changes in cache -- cgit v1.2.3 From c268cfc267a71254881a85975504f0a3e0e69815 Mon Sep 17 00:00:00 2001 From: Hugues Date: Thu, 20 Mar 2008 12:10:42 +0100 Subject: Correction colors --- 11_Colors.zsh | 6 +++++- 12_Prompts.zsh | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/11_Colors.zsh b/11_Colors.zsh index c76fd95..db68bb1 100644 --- a/11_Colors.zsh +++ b/11_Colors.zsh @@ -13,7 +13,7 @@ _c=m C_="%{$c_" _C="$_c%}" -typeset -A prompt_colors git_colors mail_colors +typeset -A prompt_colors git_colors mail_colors correct_colors # I hate kik00l0l colorized prompts, so I'm using a way to # give a dominant color for each part of the prompt, each of @@ -81,3 +81,7 @@ set_prompt_colors () } set_prompt_colors + +correct_colors[error]="$color[red];$color[bold]" +correct_colors[suggest]="$color[blue];$color[bold]" + diff --git a/12_Prompts.zsh b/12_Prompts.zsh index d9ae9fa..a5b7348 100644 --- a/12_Prompts.zsh +++ b/12_Prompts.zsh @@ -172,5 +172,5 @@ PS4="+%N:%i> " #RPS1="%(?;;"$C_$prompt_colors[error]$_C"%?"$C_$color[none]$_C")" # Ultime : prompt de correction :-) -SPROMPT="zsh: $C_$color[blue]$_C%B'%R'%b$C_$color[none]$_C ? Vous ne vouliez pas plutôt $C_$color[magenta]$_C%B'%r'%b$C_$color[none]$_C ? [%BN%byae] " +SPROMPT="zsh: $C_$correct_colors[error]$_C'%R'$C_$color[none]$_C ? Vous ne vouliez pas plutôt $C_$correct_colors[suggest]$_C'%r'$C_$color[none]$_C ? [%BN%byae] " -- cgit v1.2.3 From a2c7933ea8c0f37a29809e371b754214c27e8633 Mon Sep 17 00:00:00 2001 From: Hugues Date: Wed, 26 Mar 2008 14:35:11 +0100 Subject: Corrects ESC- keybinding. --- user:hugues/KeyBindings.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user:hugues/KeyBindings.zsh b/user:hugues/KeyBindings.zsh index 02c114f..b9d43f5 100644 --- a/user:hugues/KeyBindings.zsh +++ b/user:hugues/KeyBindings.zsh @@ -217,7 +217,7 @@ bindkey -s 'M' 'make ' bindkey -s 'l' 'Q l\n' #bindkey -s 'L' 'Q la\n' -bindkey -s ' ' '\\\\ ' +bindkey -s ' ' '\\ ' bindkey -s 'g' 'Q git-status\n' bindkey -s 'G' 'Q git-repack\n' -- cgit v1.2.3 From b86da16524342d1da6bdef8f2bd30cffa7099c1f Mon Sep 17 00:00:00 2001 From: Hugues Date: Wed, 26 Mar 2008 14:35:34 +0100 Subject: Mail received other than important ones colorized in $generic instead of $red. --- 11_Colors.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/11_Colors.zsh b/11_Colors.zsh index db68bb1..ab455ca 100644 --- a/11_Colors.zsh +++ b/11_Colors.zsh @@ -68,7 +68,7 @@ set_prompt_colors () prompt_colors[exec]="$color[none]" # command output mail_colors[unread]="$color[yellow];$color[bold]" # mail received - mail_colors[listes]="$color[red];$color[bold]" # less important mail received + mail_colors[listes]="$my_generic;$color[bold]" # less important mail received prompt_colors[up_to_date]="$my_generic" # up-to-date prompt_colors[not_up_to_date]="$color[green];$color[bold]" # not up to date -- cgit v1.2.3 From a29f80d7684c725d81e8923d5d680384f7078db7 Mon Sep 17 00:00:00 2001 From: Hugues Date: Wed, 26 Mar 2008 14:36:10 +0100 Subject: Zlogin lightened. --- .zlogin | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.zlogin b/.zlogin index 4bec47e..8cb3d01 100644 --- a/.zlogin +++ b/.zlogin @@ -2,10 +2,14 @@ #for _col in {1..$COLUMNS} ; do echo -n "_" ; done ;\ echo;\ preprint "événements" $color[bold] ; echo cmd_exists when && when w --calendar=~/.when/birthdays -cmd_exists calendar && calendar -A0 | sed "s/\(\*.*\)/\1/;s/\(\*.*\*\)/\1/" ;\ +#cmd_exists calendar && calendar -A0 | sed "s/\(\*.*\)/\1/;s/\(\*.*\*\)/\1/" ;\ -preprint "calendrier" $color[bold] ; echo -[ -x ~/sbin//calendrier ] && ~/sbin/calendrier +cmd_exists screen && [ "$(find /var/run/screen/S-$USER/ ! -type d | wc -l)" -gt 0 ] &&\ +preprint "screen" $color[bold] && echo &&\ +screen -list + +#preprint "calendrier" $color[bold] ; echo +#[ -x ~/sbin//calendrier ] && ~/sbin/calendrier #cmd_exists remind && remind -n # -- cgit v1.2.3