From 9c9301cd7552d758172f8bde1c28085e700f7306 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Wed, 7 Nov 2018 10:34:42 +0100 Subject: Modifs en vrac.... (Sérieusement !?) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .zlogin | 36 ++++++++++++++- 01_Internal.zsh | 13 ++++-- 10_Environment.zsh | 33 ++++++++------ 12_Prompts.zsh | 107 ++++++++++++++------------------------------ 99_Exec.zsh | 11 +---- user:hugues/Aliases.zsh | 15 +++++-- user:hugues/Environment.zsh | 4 +- user:hugues/GusBindings.zsh | 2 +- zshrc | 1 + 9 files changed, 113 insertions(+), 109 deletions(-) diff --git a/.zlogin b/.zlogin index 280fe3b..b59bef9 100644 --- a/.zlogin +++ b/.zlogin @@ -1,6 +1,40 @@ +if ( ! __zsh_status ) +then + echo + echo -n $c_$_prompt_colors[warning]$_c + #toilet -f bigmono9 "D1rTY Zsh.." -__cmd_exists keychain && eval $(keychain) + HBAR=${${(l:13::q:)}//q/$_tq_} + VBAR=$T_$_tx_$_T + + echo + echo -n " " + echo -n $T_$_tl_ + echo -n $HBAR + echo -n $_tk_$_T + echo + echo " $VBAR WARNING !! $VBAR" + echo " $VBAR D1rTY Zsh.. $VBAR" + + echo -n " " + echo -n $T_$_tm_ + echo -n $HBAR + echo -n $_tj_$_T + echo + echo $c_$_prompt_colors[none]$_c +fi + +__cmd_exists keychain && eval $(keychain --inherit any --eval) __cmd_exists when && when +if __cmd_exists fortune +then + __preprint "Pensée du jour" + fortune | fmt -s -w 74 + __preprint + echo +fi | sed 's/^/ /' + + true diff --git a/01_Internal.zsh b/01_Internal.zsh index a73772c..42d4af4 100644 --- a/01_Internal.zsh +++ b/01_Internal.zsh @@ -26,6 +26,8 @@ __cmd_exists () which -p $1 >/dev/null 2>&1 } +__cmd_exists keychain && eval $(keychain --inherit any --eval --quiet) + __term_title() { __debug -n " Term title..." @@ -49,12 +51,15 @@ __term_title() then case $TERM in sun-cmd) + __debug -n "\n - sun" print -Pn "\e]l%n@%m %~$@\e\\" # Never tested.. ;; *term*|rxvt*|putty) + __debug -n "\n - term/rxvt/putty" print -Pn "\e]0;%n@%m (%l) %~${@//\%/%%}\a" # Sets term title ;; screen*) + __debug -n "\n - screen" local _sep="" [ $# -gt 0 ] && _sep=$1 && shift # gets and discards the separator, if any. # Tmux @@ -303,15 +308,15 @@ __get_git_branch () onto=$(git name-rev --name-only --always --no-undefined $(cat $REBASE_DIR/onto) 2>&- | __cleanup_git_branch_name) # amended commit - if [ -e $REBASE_DIR/amend ] + if [ -e $REBASE_DIR/stopped-sha ] + then + amend=$(cat $REBASE_DIR/stopped-sha) + elif [ -e $REBASE_DIR/amend ] then amend=$(cat $REBASE_DIR/amend) elif [ -e $REBASE_DIR/original-commit ] then amend=$(cat $REBASE_DIR/original-commit) - elif [ -e $REBASE_DIR/stopped-sha ] - then - amend=$(cat $REBASE_DIR/stopped-sha) fi # if [ "$amend" != "$commit_ish" ] diff --git a/10_Environment.zsh b/10_Environment.zsh index ce82154..714172f 100644 --- a/10_Environment.zsh +++ b/10_Environment.zsh @@ -26,28 +26,33 @@ _c=m C_="%{$c_" _C="$_c%}" -unset has_termcaps +unset _has_tcaps case "$( _process_tree )" in *":: SCREEN ::"*) # Discards termcaps even if screen is launched from an urxvt.. ;; *":: "*"urxvt ::"*|\ *":: tmux ::"*) - has_termcaps="true" + has_termcaps=${has_termcaps:-true} ;; *) ;; esac -T_=${has_termcaps:+$termcap[as]} -_T=${has_termcaps:+$termcap[ae]} -_tq_=${${has_termcaps:+"q"}:-"-"} -_tj_=${${has_termcaps:+"j"}:-"'"} -_tk_=${${has_termcaps:+"k"}:-"."} -_tl_=${${has_termcaps:+"l"}:-","} -_tm_=${${has_termcaps:+"m"}:-"\`"} -_tt_=${${has_termcaps:+"t"}:-"]"} -_tu_=${${has_termcaps:+"u"}:-"["} -_tx_=${${has_termcaps:+"x"}:-"|"} +_has_tcaps="${has_termcaps}" +[ "${_has_tcaps}" != "true" ] && unset _has_tcaps + +T_=${_has_tcaps:+$termcap[as]} +_T=${_has_tcaps:+$termcap[ae]} +_tq_=${${_has_tcaps:+"q"}:-"-"} +_tj_=${${_has_tcaps:+"j"}:-"'"} +_tk_=${${_has_tcaps:+"k"}:-"."} +_tl_=${${_has_tcaps:+"l"}:-","} +_tm_=${${_has_tcaps:+"m"}:-"\`"} +_tt_=${${_has_tcaps:+"t"}:-"]"} +_tu_=${${_has_tcaps:+"u"}:-"["} +_tx_=${${_has_tcaps:+"x"}:-"|"} +# Not needed anymore +unset _has_tcaps # I hate kik00l0l colorized prompts, so I'm using a way to # give a dominant color for each part of the prompt, each of @@ -94,9 +99,11 @@ HISTSIZE=$(( $SAVEHIST * 1.10 )) export GPG_TTY=`tty` # YeahConsole.. -if ( ps x 2>&- | grep $$ -B1 | grep -q yeahconsole ) +if ( ps 2>&- | grep $$ -B1 | grep -q yeahconsole ) then _yeahconsole=true +else + _yeahconsole=false fi # Display guess diff --git a/12_Prompts.zsh b/12_Prompts.zsh index 18508a4..6537b07 100644 --- a/12_Prompts.zsh +++ b/12_Prompts.zsh @@ -176,52 +176,45 @@ __ssh_gpg_agents () } PS1_TASKBAR+=(__ssh_gpg_agents) +__display () +{ + __debug -n " Display..." + echo ${DISPLAY:+$C_$_prompt_colors[display]$_C"("$DISPLAY")"} + __debug +} +PS1_TASKBAR+=(__display) + __battery() { __debug -n " Battery..." - # POWERADAPTER=$(grep "^AC Power" /proc/pmu/info | cut -c26) - - # typeset -A battery - # battery[remaining]=$(grep "^time rem" /proc/pmu/battery_0 | cut -c14- ) - # battery[remain_hrs]=$(( $battery[remaining] / 3600 )) - # battery[remain_min]=$(( ($battery[remaining] - ( $battery[remain_hrs] * 3600 )) / 60 )) - # [ "$battery[remain_min]" -lt 10 ] && battery[remain_min]="0"$battery[remain_min] - # battery[remains]=$battery[remain_hrs]"h"$battery[remain_min] - - # BATTERYSIZE=$(( ${#battery[remains]} + 1 )) - - # battery[load]=$(grep "^current" /proc/pmu/battery_0 | cut -c14- ) - - # if [ $POWERADAPTER -ne 0 ] - # then - # battery[color]="charging" - # if [ $battery[load] -eq 0 ] - # then - # ## Battery full - # BATTERYSIZE=2 - # battery[remains]="⚡" - # fi - # else - # if [ $battery[remaining] -lt 659 ] - # then - # battery[color]="critical" - # else - # battery[color]="uncharging" - # fi - # fi - BATTPERCENT=$(acpi -b | cut -d, -f2 | tr -d ' %') - echo -n $termcap[as]"u" + POWER=$(acpi -a | grep -q 'on-line' ; echo $?) + BATTCHARGING=$(acpi -b | grep -q 'Charging' ; echo $?) + + if [ "$POWER" -eq 0 -a ! "$BATTCHARGING" -eq 0 ] + then + return + fi + + echo -n $termcap[as] + echo -n "u" if [ $BATTPERCENT -le 10 ] then echo -n $C_"31"$_C elif [ $BATTPERCENT -le 25 ] then - echo -n $C_"33"$_C + echo -n $C_"33;1"$_C + else + if [ $POWER -eq 0 ] + then + echo -n $C_"44;34;1"$_C + else + echo -n $C_"34;1"$_C + fi fi - for i in {0..9} + for i in {0..4} do - if [ $i -le $(($BATTPERCENT / 10)) ] + if [ $i -le $(($BATTPERCENT / 20)) ] then echo -n "a" else @@ -229,18 +222,11 @@ __battery() { fi done echo -n $C_$_prompt_colors[generic]$_C - echo -n "t"$termcap[ae] + echo -n "t" + echo -n $termcap[ae] __debug } -which acpi && PS1_TASKBAR+=(__battery) - -__display () -{ - __debug -n " Display..." - echo ${DISPLAY:+$C_$_prompt_colors[display]$_C"("$DISPLAY")"} - __debug -} -PS1_TASKBAR+=(__display) +__cmd_exists acpi && PS1_TASKBAR+=(__battery) __vcsbranch () { @@ -320,7 +306,7 @@ __subvcsbranches () { echo $GITBRANCH } -PS1_TASKBAR+=(__subvcsbranches) +#PS1_TASKBAR+=(__subvcsbranches) __redefine_prompt () { @@ -332,6 +318,7 @@ __redefine_prompt () __two_lines_prompt ;; esac + setterm -cursor on } zle -N __redefine_prompt @@ -402,32 +389,6 @@ __two_lines_prompt () } -if ( ! __zsh_status ) -then - echo - echo -n $c_$_prompt_colors[warning]$_c - #toilet -f bigmono9 "D1rTY Zsh.." - - HBAR=${${(l:13::q:)}//q/$_tq_} - VBAR=$T_$_tx_$_T - - echo - echo -n " " - echo -n $T_$_tl_ - echo -n $HBAR - echo -n $_tk_$_T - echo - echo " $VBAR WARNING !! $VBAR" - echo " $VBAR D1rTY Zsh.. $VBAR" - - echo -n " " - echo -n $T_$_tm_ - echo -n $HBAR - echo -n $_tj_$_T - echo - echo $c_$_prompt_colors[none]$_c -fi - precmd() { # Catchs ERROR code @@ -437,8 +398,6 @@ precmd() __redefine_prompt } - - # Prompt level 3 PS3="?# " diff --git a/99_Exec.zsh b/99_Exec.zsh index e8f8a1a..612b487 100644 --- a/99_Exec.zsh +++ b/99_Exec.zsh @@ -8,13 +8,4 @@ ## these files with or without this notice. ## -if __cmd_exists fortune -then - __preprint "Pensée du jour" - fortune | fmt -s -w 74 - __preprint - echo -fi | sed 's/^/ /' - -chpwd - +cd . diff --git a/user:hugues/Aliases.zsh b/user:hugues/Aliases.zsh index aefe795..99304f8 100644 --- a/user:hugues/Aliases.zsh +++ b/user:hugues/Aliases.zsh @@ -7,8 +7,8 @@ ## You are encouraged to use, modify, and redistribute ## these files with or without this notice. ## -a -g ¬ISO='LC_ALL=fr_FR' -a -g ¬UTF='LC_ALL=fr_FR.UTF-8' +a -g ¬ISO='LC_ALL=br_FR' +a -g ¬UTF='LC_ALL=br_FR.UTF-8' a -g ...=../.. a -g ....=../../.. @@ -17,9 +17,16 @@ a -g ......=../../../../.. a -g .......=../../../../../.. a -g ........=../../../../../../.. a -g .........=../../../../../../../.. - +a -g ..........=../../../../../../../../.. +a -g ...........=../../../../../../../../../.. +a -g ............=../../../../../../../../../../.. +a -g .............=../../../../../../../../../../../.. +a -g ..............=../../../../../../../../../../../../.. +a -g ...............=../../../../../../../../../../../../../.. +a -g ................=../../../../../../../../../../../../../../.. + if ( __cmd_exists emacs ) -then +then a e='emacs' a ne='e -nw' a gnus='e -f gnus' diff --git a/user:hugues/Environment.zsh b/user:hugues/Environment.zsh index 112110e..492fdc9 100644 --- a/user:hugues/Environment.zsh +++ b/user:hugues/Environment.zsh @@ -35,8 +35,8 @@ export LESS="-R -F -X" export NULLCMD=cat # Locale en français unicode -export LC_ALL=${LC_ALL:-fr_FR.UTF-8} -export LC_MESSAGES=${LC_MESSAGES:-fr_FR} +export LC_ALL=${LC_ALL:-br_FR.UTF-8} +export LC_MESSAGES=${LC_MESSAGES:-br_FR} unset LANG # Unuseful # Utilisation des commandes git-* diff --git a/user:hugues/GusBindings.zsh b/user:hugues/GusBindings.zsh index b156e68..1d29f50 100644 --- a/user:hugues/GusBindings.zsh +++ b/user:hugues/GusBindings.zsh @@ -220,7 +220,7 @@ do bindkey -M $keymap -s '^[c' '^[Q configure\n' bindkey -M $keymap -s '^[©' '^[Q !?configure\n' - alias MAKE="[ ! -e Makefile -a ! -e GNUmakefile ] && ( [ ! -e configure ] && ./autogen.sh ; ./configure && make ) || make" + alias MAKE="[ ! -e Makefile -a ! -e GNUmakefile ] && ( [ ! -e configure ] && [ -e autogen.sh ] && ./autogen.sh || [ -e configure.ac ] && autoreconf --install ; ./configure && make ) || make" bindkey -M $keymap -s '^[m' '^[Q MAKE\n' bindkey -M $keymap -s '^[M' '^[Q make\n' diff --git a/zshrc b/zshrc index 499ad3c..8f57c44 100644 --- a/zshrc +++ b/zshrc @@ -43,6 +43,7 @@ DOMAIN=${DOMAIN:-$(hostname -y 2>&-)} ## Agent de clefs SSH/GPG KEYCHAIN=~/.keychain/$(hostname)-sh +keychain -q [ -r "${KEYCHAIN}" ] && source ${KEYCHAIN} [ -r "${KEYCHAIN}-gpg" ] && source ${KEYCHAIN}-gpg -- cgit v1.2.3