Modification : vm_remote : rule_git_configure : stockage du dépôt distant dans notre...
[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 users="$(who -u | cut -d " " -f 1 | sort -u)"
56 test "$(printf "%s\n" $users | wc -l)" -lt 2 || {
57 users=$(printf "%s&" $users)
58 printf "%s@" "${users%&}"
59 }
60 }
61 prompt_text="\\[$tput_setaf_3$tput_bold\\]\$(prompt_users)\\[$tput_sgr0\\]$prompt_text"
62 prompt_text="\\[$tput_setaf_1$tput_bold\\]\$(prompt_etckeeper)\\[$tput_sgr0\\]$prompt_text"
63 PS1="$prompt_set_cursor$prompt_text"
64
65 # NOTE: couleurs
66 eval $(dircolors --bourne-shell)
67
68 # NOTE: alias
69 alias cl='clear'
70 alias dux='du -cks * | sort -rn | head -11'
71 alias e='sudo etckeeper'
72 alias ec='sudo etckeeper commit'
73 alias ev='sudo etckeeper vcs'
74 alias l='ls'
75 la ()
76 {
77 local GLOBIGNORE
78 GLOBIGNORE=non-null
79 if [ -z "${@:+set}" ]
80 then chacl -l . .. *
81 else chacl -l "$@"
82 fi
83 }
84 alias ll='ls -l'
85 lll ()
86 {
87 local GLOBIGNORE
88 GLOBIGNORE=non-null
89 eval "$(if [ -z "${@:+set}" ]
90 then getfacl --absolute-names ${ACLOPTS:---physical} . .. *
91 else getfacl --absolute-names ${ACLOPTS:---physical} "$@"
92 fi |
93 sed -e '/^\# file: /{
94 N
95 ;N
96 ;x
97 ;s/.*//
98 ;N
99 ;s/^\n\# flags: \([^ ]*\)/f:\1/
100 ;s/^\n//
101 ;: loop
102 ;s/\s*\#effective:\(...\)$/'"$tput_setaf_1"'('"$tput_sgr0"'\1'"$tput_setaf_1"')'"$tput_sgr0"'/
103 ;s/ default:\([^:]\)[^:][^:]*:\([^:]*\):/'"$tput_setaf_0$tput_bold"' d:'"$tput_setaf_0$tput_bold"'\1:'"$tput_sgr0"'\2'"$tput_setaf_0$tput_bold"':'"$tput_sgr0"'/
104 ;s/\(^\| \)\([^:]\)[^:]*:\([^:]*\):\([^:]*\)$/\1'"$tput_setaf_0$tput_bold"'\2:'"$tput_sgr0"'\3'"$tput_setaf_0$tput_bold"':'"$tput_sgr0"'\4/
105 ;N
106 ;s/\n\(.\)/ \1/
107 ;t loop
108 ;s/\n$//
109 ;s/^f:\([^ ]*\) \([^\n]*\)/\2 '"$tput_setaf_0$tput_bold"'f:'"$tput_sgr0"'\1/
110 ;H
111 ;x
112 ;s/^\# file: \([^\n]*\)\n\# owner: \([^\n]*\)\n\# group: \([^\n]*\)\n\(.*\)/ \
113 echo -En '"'"'\2'"$tput_setaf_0$tput_bold:$tput_sgr0"'\3 \4 '"'"'; \
114 ls --color=always -d "$(echo -en '"'"'\1'"'"')"/
115 }'
116 )"
117 }
118 alias ls='ls -aFh -T 0 --color=auto'
119 alias scan='clamdscan --fdpass'
120 alias setfacl='setfacl --no-mask'
121 alias sl='ls'
122 alias vi='vim'
123 alias vim='vim -p'
124 alias vm_hosted='~/src/vm/vm_hosted'
125 alias vm='vm_hosted'
126 alias :e='vim'
127 alias :q='exit'
128
129 # enable bash completion in interactive shells
130 if [ -f /etc/bash_completion ]
131 then . /etc/bash_completion
132 fi
133
134 mkdir -p ~/var/log/"${SHELL##*/}"
135 HISTFILE=~/var/log/"${SHELL##*/}"/history.log
136 HISTCONTROL=ignoreboth
137 shopt -s histappend