Corrections: etc/nsd/zone.d/* - Champ SPF déprécié
[lhc/ateliers.git] / etc / bash.bashrc
1 # System-wide .bashrc file for interactive bash(1) shells.
2
3 # To enable the settings / commands in this file for login shells as well,
4 # this file has to be sourced in /etc/profile.
5
6 # NOTE: if not running interactively, don't do anything
7 [ -z "$PS1" ] && return
8
9 [ "${SHELL##*\/}" = bash ] && {
10 # NOTE: check the window size after each command and, if necessary,
11 # update the values of LINES and COLUMNS.
12 shopt -s checkwinsize
13 }
14
15 # NOTE: set variable identifying the chroot you work in (used in the prompt below)
16 if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]
17 then debian_chroot=$(cat /etc/debian_chroot)
18 fi
19
20 # NOTE: set a fancy prompt (non-color, overwrite the one in /etc/profile)
21 #PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
22
23 # NOTE: séquences d’échappement du terminal
24 for i in {0..7}
25 do declare tput_setaf_$i="$(tput setaf $i)"
26 done
27 tput_sgr0="$(tput sgr0)"
28 tput_cnorm="$(tput cnorm)"
29 tput_bold="$(tput bold)"
30 tput_rev="$(tput rev)"
31
32 # NOTE: met un gros curseur bleu non-clignotant dans un TTY
33 # VOIR: /usr/src/linux/Documentation/VGA-softcursor.txt
34 case $TERM in
35 (*linux) prompt_set_cursor="$tput_cnorm\e[?16;0;16c" ;;
36 # NOTE: last 16 does not seem to be portable
37 # and you may have to change it to get the right color.
38 (*) prompt_set_cursor=$tput_cnorm ;;
39 esac
40 prompt_set_cursor="\\[$prompt_set_cursor\\]"
41 alias prompt_errno='test $? = 0 || printf %s "$tput_setaf_1"'
42 prompt_text="\\[$tput_setaf_6\\]\\w\\[$tput_sgr0\\] \\[\$(prompt_errno)\\]\\$\\[$tput_sgr0\\] "
43 # NOTE: encapsule pour passer l’interprétation de screen
44 case $TERM in
45 (screen*) [ -z "$prompt_set_cursor" ] ||
46 prompt_set_cursor="\\[\eP\\]$prompt_set_cursor\\[\e\\\\\\]"
47 ;;
48 (*)
49 # NOTE: rajoute l’hôte quand il n’y a pas screen pour l’afficher
50 prompt_text="\\[$tput_setaf_0$tput_bold\\]\\h $prompt_text"
51 ;;
52 esac
53 . /etc/etckeeper/prompt.sh
54 prompt_users () {
55 local errno=$?;
56 local users="$(who -u | cut -d " " -f 1 | sort -u)"
57 test "$(printf "%s\n" $users | wc -l)" -lt 2 || {
58 users=$(printf "%s&" $users)
59 printf "%s@" "${users%&}"
60 }
61 exit $errno
62 }
63 prompt_text="\\[$tput_setaf_3$tput_bold\\]\$(prompt_users)\\[$tput_sgr0\\]$prompt_text"
64 prompt_text="\\[$tput_setaf_1$tput_bold\\]\$(prompt_etckeeper)\\[$tput_sgr0\\]$prompt_text"
65 PS1="$prompt_set_cursor$prompt_text"
66
67 # NOTE: couleurs
68 eval $(dircolors --bourne-shell)
69
70 # NOTE: alias
71 alias cl='clear'
72 alias dux='du -cks * | sort -rn | head -11'
73 alias e='sudo etckeeper'
74 alias ec='sudo etckeeper commit'
75 alias ev='sudo etckeeper vcs'
76 alias l='ls'
77 la ()
78 {
79 local GLOBIGNORE
80 GLOBIGNORE=non-null
81 if [ -z "${@:+set}" ]
82 then chacl -l . .. *
83 else chacl -l "$@"
84 fi
85 }
86 alias ll='ls -l'
87 lll ()
88 {
89 local GLOBIGNORE
90 GLOBIGNORE=non-null
91 eval "$(if [ -z "${@:+set}" ]
92 then getfacl --absolute-names ${ACLOPTS:---physical} . .. *
93 else getfacl --absolute-names ${ACLOPTS:---physical} "$@"
94 fi |
95 sed -e '/^\# file: /{
96 N
97 ;N
98 ;x
99 ;s/.*//
100 ;N
101 ;s/^\n\# flags: \([^ ]*\)/f:\1/
102 ;s/^\n//
103 ;: loop
104 ;s/\s*\#effective:\(...\)$/'"$tput_setaf_1"'('"$tput_sgr0"'\1'"$tput_setaf_1"')'"$tput_sgr0"'/
105 ;s/ default:\([^:]\)[^:][^:]*:\([^:]*\):/'"$tput_setaf_0$tput_bold"' d:'"$tput_setaf_0$tput_bold"'\1:'"$tput_sgr0"'\2'"$tput_setaf_0$tput_bold"':'"$tput_sgr0"'/
106 ;s/\(^\| \)\([^:]\)[^:]*:\([^:]*\):\([^:]*\)$/\1'"$tput_setaf_0$tput_bold"'\2:'"$tput_sgr0"'\3'"$tput_setaf_0$tput_bold"':'"$tput_sgr0"'\4/
107 ;N
108 ;s/\n\(.\)/ \1/
109 ;t loop
110 ;s/\n$//
111 ;s/^f:\([^ ]*\) \([^\n]*\)/\2 '"$tput_setaf_0$tput_bold"'f:'"$tput_sgr0"'\1/
112 ;H
113 ;x
114 ;s/^\# file: \([^\n]*\)\n\# owner: \([^\n]*\)\n\# group: \([^\n]*\)\n\(.*\)/ \
115 echo -En '"'"'\2'"$tput_setaf_0$tput_bold:$tput_sgr0"'\3 \4 '"'"'; \
116 ls --color=always -d "$(echo -en '"'"'\1'"'"')"/
117 }'
118 )"
119 }
120 alias ls='ls -aFh -T 0 --color=auto'
121 alias mem='ps -e -orss=,user=,args= | sort -b -k1,1n'
122 alias scan='clamdscan --fdpass'
123 alias setfacl='setfacl --no-mask'
124 alias sl='ls'
125 alias vi='vim'
126 alias vim='vim -p'
127 alias :e='vim'
128 alias :q='exit'
129
130 # enable bash completion in interactive shells
131 if [ -f /etc/bash_completion ]
132 then . /etc/bash_completion
133 fi
134
135 mkdir -p ~/var/log/"${SHELL##*/}"
136 HISTFILE=~/var/log/"${SHELL##*/}"/history.log
137 HISTCONTROL=ignoreboth
138 shopt -s histappend