Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions 01_Functions.zsh

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ message de commit : corriger l’erreur de Fphrapppe

Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ preprint()
hbar=
for i in {1..$(($COLUMNS - ${#1} - 5))}
do
hbar=$hbar-
hbar=${hbar}q

@hugues hugues Oct 18, 2023

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • réindenter le code

done
print -Pn "${C_}$my_color${_C}${hbar}[ $1 ]-\r${C_}0${_C}"
hbar=$termcap[as]$hbar$termcap[ae]

print -Pn "${C_}$my_color${_C}${hbar}$termcap[as]u$termcap[ae] $1 $termcap[as]tq$termcap[ae]\r${C_}0${_C}"
}

get_git_branch ()
Expand Down
28 changes: 28 additions & 0 deletions 10_Environment.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,34 @@ _c=m
C_="%{$c_"
_C="$_c%}"

## Termcaps ###########################

# Activates the alternate charset
echo $termcap[eA]

typeset -A chars

chars['-']="$termcap[as]q$termcap[ae]"
chars['|']="$termcap[as]x$termcap[ae]"

chars[lr]="$termcap[as]j$termcap[ae]"
chars[ur]="$termcap[as]k$termcap[ae]"
chars[ul]="$termcap[as]l$termcap[ae]"
chars[ll]="$termcap[as]m$termcap[ae]"

chars['+']="$termcap[as]n$termcap[ae]"

chars[rT]="$termcap[as]t$termcap[ae]"
chars[lT]="$termcap[as]u$termcap[ae]"
chars[uT]="$termcap[as]v$termcap[ae]"
chars[dT]="$termcap[as]w$termcap[ae]"

Comment on lines +55 to +58

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oulah

chars[uA]="$termcap[as]A$termcap[ae]"
chars[dA]="$termcap[as]B$termcap[ae]"
chars[rA]="$termcap[as]C$termcap[ae]"
chars[lA]="$termcap[as]D$termcap[ae]"


## Variables d'environnement ``classiques''
#
# L'utilisation de la forme ${VARIABLE:+$VARIABLE:} permet d'accoler ``:''
Expand Down
6 changes: 1 addition & 5 deletions 11_Colors.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,12 @@ set_prompt_colors ()
my_generic=${1:-$prompt_colors[generic]}

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];$my_generic" # <login>@<hostname>
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]="$my_generic;$color[bold]" # horizontal bar
prompt_colors[braces]="$prompt_colors[bar]" # braces (around date)
prompt_colors[border]="$my_generic;$color[bold]" # horizontal bar
prompt_colors[error]="$color[bold];$color[yellow]" # error code
prompt_colors[date]="$my_generic" # full date

Expand Down
25 changes: 12 additions & 13 deletions 12_Prompts.zsh

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ preexec ()

expand_text()
{
# strips the %{...%}
print -Pn -- "$(echo $@ | sed 's/%{[^(%})]*%}//g')"
# strips the %{...%} and $termcap special keys
print -Pn -- $(echo $@ | sed "s/%{[^(%})]*%}//g;s/$termcap[as]//g;s/$termcap[ae]//g")
}

new_precmd()
Expand All @@ -48,18 +48,18 @@ new_precmd()
typeset -A ERROR DATE MAILS LOGIN HOST CWD GITINFO SVNINFO PRECMD
ERROR[color] = $prompt_colors[error]
ERROR[string] = "%(?;;%?)"
ERROR[pre] = "-"
ERROR[pre] = $chars['-']
ERROR[post] =
ERROR[size] = ${#$(print -Pn $ERROR[pre]$ERROR[string]$ERROR[post])}
ERROR[size] = ${#$(expand_text $ERROR[pre]$ERROR[string]$ERROR[post])}
}

old_precmd()
{
# Error
error=$(print -Pn "%(?;;-%?)")
[ "$DEBUG" = "yes" ] && echo -n " Error code..."
[ "$DEBUG" = "yes" ] && echo -n " Error code... ($error)"
ERRORSIZE=${#error}
ERROR="%(?;;"$C_$prompt_colors[bar]$_C"-"$C_$prompt_colors[error]$_C"%?)"
ERROR="%(?;;$C_$prompt_colors[border]$_C"-"$C_$prompt_colors[error]$_C%?)"
[ "$DEBUG" = "yes" ] && echo

[ "$DEBUG" = "yes" ] && echo -n " Term title..."
Expand All @@ -69,26 +69,26 @@ old_precmd()

# Date
[ "$DEBUG" = "yes" ] && echo -n " 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"-"
DATE=$C_$prompt_colors[border]$_C"$chars[lT] "$C_$prompt_colors[date]$_C"%D{%a-%d-%b-%Y %H:%M:%S}"$C_$prompt_colors[border]$_C" $chars[rT]"$C_$prompt_colors[border]$_C$chars['-']
DATEEXPAND=$(expand_text "$DATE")
DATESIZE=${#DATEEXPAND}
[ "$DEBUG" = "yes" ] && echo

# Mailcheck
[ "$DEBUG" = "yes" ] && echo -n " Mails..."
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""@" } }'`")
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[border]$_C'-'$C_$mail_colors[unread]$_C""@" } else if (LISTES > 0) { print "$C_$prompt_colors[border]$_C'-'$C_$mail_colors[listes]$_C""@" } }'`")
MAILSTATEXPAND=$(expand_text "$MAILSTAT")
MAILSTATSIZE=${#MAILSTATEXPAND}
[ "$DEBUG" = "yes" ] && echo

[ "$DEBUG" = "yes" ] && echo -n " Horizontal bar..."
# First line of prompt, calculation of the remaining place
spaceleft=$((1 + $COLUMNS - $ERRORSIZE - $MAILSTATSIZE - $DATESIZE))
spaceleft=$((1 + $COLUMNS - $ERRORSIZE - $MAILSTATSIZE - $DATESIZE + 6))

unset HBAR
for h in {1..$(($spaceleft - 1))}
for h in {1..$spaceleft}
do
HBAR=$HBAR-
HBAR=$HBAR$chars['-']
done
[ "$DEBUG" = "yes" ] && echo

Expand Down Expand Up @@ -160,10 +160,9 @@ old_precmd()
# 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
PS1="$MAILSTAT""$ERROR"$C_$prompt_colors[border]$_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()
Expand Down