Ajout : rule_user_configure : bash, screen, etckeeper .
[lhc/ateliers.git] / etc / bash.bashrc
diff --git a/etc/bash.bashrc b/etc/bash.bashrc
new file mode 100644 (file)
index 0000000..ae5f5b1
--- /dev/null
@@ -0,0 +1,126 @@
+# System-wide .bashrc file for interactive bash(1) shells.
+
+# To enable the settings / commands in this file for login shells as well,
+# this file has to be sourced in /etc/profile.
+
+# NOTE: if not running interactively, don't do anything
+[ -z "$PS1" ] && return
+
+[ "${SHELL##*\/}" = bash ] && {
+       # NOTE:  check the window size after each command and, if necessary,
+       #        update the values of LINES and COLUMNS.
+       shopt -s checkwinsize
+ }
+
+# NOTE: set variable identifying the chroot you work in (used in the prompt below)
+if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]
+ then debian_chroot=$(cat /etc/debian_chroot)
+ fi
+
+# NOTE: set a fancy prompt (non-color, overwrite the one in /etc/profile)
+#PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
+
+# NOTE: séquences d’échappement du terminal
+for i in {0..7}
+ do declare tput_setaf_$i="$(tput setaf $i)"
+ done
+tput_sgr0="$(tput sgr0)"
+tput_cnorm="$(tput cnorm)"
+tput_bold="$(tput bold)"
+tput_rev="$(tput rev)"
+
+# NOTE: met un gros curseur bleu non-clignotant dans un TTY
+# VOIR: /usr/src/linux/Documentation/VGA-softcursor.txt
+case $TERM in
+ (*linux) prompt_set_cursor="$tput_cnorm\e[?16;0;16c" ;;
+       # NOTE: last 16 does not seem to be portable
+       #       and you may have to change it to get the right color.
+ (*) prompt_set_cursor=$tput_cnorm ;;
+ esac
+prompt_set_cursor="\\[$prompt_set_cursor\\]"
+alias prompt_errno='test $? = 0 || printf %s "$tput_setaf_1"'
+prompt_text="\\[$tput_setaf_6\\]\\w\\[$tput_sgr0\\] \\[\$(prompt_errno)\\]\\$\\[$tput_sgr0\\] "
+# NOTE: encapsule pour passer l’interprétation de screen
+case $TERM in
+ (screen*) [ -z "$prompt_set_cursor" ] ||
+               prompt_set_cursor="\\[\eP\\]$prompt_set_cursor\\[\e\\\\\\]"
+       ;;
+ (*)
+       # NOTE: rajoute l’hôte quand il n’y a pas screen pour l’afficher
+       prompt_text="\\[$tput_setaf_0$tput_bold\\]\\h $prompt_text"
+       ;;
+ esac
+. /etc/etckeeper/prompt.sh
+PS1="$prompt_set_cursor\\[$tput_setaf_1$tput_bold\\]\$(prompt_etckeeper)\\[$tput_sgr0\\]$prompt_text"
+
+# NOTE: couleurs
+eval $(dircolors --bourne-shell)
+
+# NOTE: alias
+alias cl='clear'
+alias dux='du -cks * | sort -rn | head -11'
+alias e='sudo etckeeper'
+alias ec='sudo etckeeper commit'
+alias ev='sudo etckeeper vcs'
+alias l='ls'
+la ()
+ {
+       local GLOBIGNORE
+       GLOBIGNORE=non-null
+       if [ -z "${@:+set}" ]
+       then chacl -l . .. *
+       else chacl -l "$@"
+       fi
+ }
+alias ll='ls -l'
+lll ()
+ {
+       local GLOBIGNORE
+       GLOBIGNORE=non-null
+       eval "$(if [ -z "${@:+set}" ]
+               then getfacl --absolute-names ${ACLOPTS:---physical} . .. *
+               else getfacl --absolute-names ${ACLOPTS:---physical} "$@"
+               fi |
+               sed -e '/^\# file: /{
+                 N
+                ;N
+                ;x
+                ;s/.*//
+                ;N
+                ;s/^\n\# flags: \([^ ]*\)/f:\1/
+                ;s/^\n//
+                ;: loop
+                ;s/\s*\#effective:\(...\)$/'"$tput_setaf_1"'('"$tput_sgr0"'\1'"$tput_setaf_1"')'"$tput_sgr0"'/
+                ;s/ default:\([^:]\)[^:][^:]*:\([^:]*\):/'"$tput_setaf_0$tput_bold"' d:'"$tput_setaf_0$tput_bold"'\1:'"$tput_sgr0"'\2'"$tput_setaf_0$tput_bold"':'"$tput_sgr0"'/
+                ;s/\(^\| \)\([^:]\)[^:]*:\([^:]*\):\([^:]*\)$/\1'"$tput_setaf_0$tput_bold"'\2:'"$tput_sgr0"'\3'"$tput_setaf_0$tput_bold"':'"$tput_sgr0"'\4/
+                ;N
+                ;s/\n\(.\)/ \1/
+                ;t loop
+                ;s/\n$//
+                ;s/^f:\([^ ]*\) \([^\n]*\)/\2 '"$tput_setaf_0$tput_bold"'f:'"$tput_sgr0"'\1/
+                ;H
+                ;x
+                ;s/^\# file: \([^\n]*\)\n\# owner: \([^\n]*\)\n\# group: \([^\n]*\)\n\(.*\)/ \
+                        echo -En '"'"'\2'"$tput_setaf_0$tput_bold:$tput_sgr0"'\3 \4    '"'"'; \
+                        ls --color=always -d "$(echo -en '"'"'\1'"'"')"/
+                }'
+        )"
+ }
+alias ls='ls -aFh -T 0 --color=auto'
+alias scan='clamdscan --fdpass'
+alias setfacl='setfacl --no-mask'
+alias sl='ls'
+alias vi='vim'
+alias vim='vim -p'
+alias :e='vim'
+alias :q='exit'
+
+# enable bash completion in interactive shells
+if [ -f /etc/bash_completion ]
+ then . /etc/bash_completion
+ fi
+
+mkdir -p ~/var/log/"${SHELL##*/}"
+HISTFILE=~/var/log/"${SHELL##*/}"/history.log
+HISTCONTROL=ignoreboth
+shopt -s histappend