Browse code

bashrc - v1.3 - Fix minor bugs

Fred authored on19/07/2014 17:52:26
Showing1 changed files
... ...
@@ -1,8 +1,8 @@
1 1
 # Title: .bashrc
2 2
 # Author: Frédéric CHEVALIER <f15.chevalier@gmail.com>
3
-# Version: 1.2
3
+# Version: 1.3
4 4
 # Created in: 2012-05-26
5
-# Modified in: 2014-07-06
5
+# Modified in: 2014-07-19
6 6
 
7 7
 
8 8
 
... ...
@@ -19,6 +19,7 @@
19 19
 # Versions #
20 20
 #==========#
21 21
 
22
+# v1.3 - 2014-07-19: bug correction for PS1 (\[\e and \] missing for each color) / typo corrections
22 23
 # v1.2 - 2014-07-06: h and t aliases corrected / m alias added / quit function added / R env variables added
23 24
 # v1.1 - 2014-07-02: bug corrections in trash function and EDITOR set up / exit and diff aliases added
24 25
 # v1.0 - 2014-06-22: file reorganization / aliases added
... ...
@@ -31,16 +32,16 @@
31 32
 #=======================#
32 33
 
33 34
 # If not running interactively, don't do anything
34
-[ -z "$PS1" ] && return
35
+[[ -z "$PS1" ]] && return
35 36
 
36 37
 # Enable programmable completion features
37
-if [ -f /etc/bash_completion ] && ! shopt -oq posix
38
+if [[ -f /etc/bash_completion ]] && ! shopt -oq posix
38 39
 then
39 40
     . /etc/bash_completion
40 41
 fi
41 42
 
42 43
 # Set variable identifying the chroot you work in (used in the prompt below)
43
-if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]
44
+if [[ -z "$debian_chroot" && -r /etc/debian_chroot ]]
44 45
 then
45 46
     debian_chroot=$(cat /etc/debian_chroot)
46 47
 fi
... ...
@@ -88,7 +89,7 @@ shopt -s cdspell
88 89
 #shopt -s autocd
89 90
 
90 91
 # Make less more friendly for non-text input files, see lesspipe(1)
91
-[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
92
+[[ -x /usr/bin/lesspipe ]] && eval "$(SHELL=/bin/sh lesspipe)"
92 93
 
93 94
 ## Key binding
94 95
 #bind '"\e[1~": beginning-of-line'		# home
... ...
@@ -128,13 +129,13 @@ then
128 129
     fi
129 130
 fi
130 131
 
131
-if [ "$color_prompt" = yes ]
132
+if [[ "$color_prompt" == "yes" ]]
132 133
 then
133
-	 if [ -n "$SSH_CONNECTION" ]
134
+	 if [[ -n "$SSH_CONNECTION" ]]
134 135
     then
135
-		PS1='\[\e[31m\][$(date +%H:%M) \u@\e[01;35m\h\e[00;36m:\[\e[33m\]\W\[\e[31m\]]\[\e[00m\]\$ '
136
+		PS1='\[\e[31m\][$(date +%H:%M) \u@\[\e[01;35m\]\h\[\e[00;31m\]:\[\e[33m\]\W\[\e[31m\]]\[\e[00m\]\$ '
136 137
 	else
137
-		PS1='\[\e[36m\][$(date +%H:%M) \u@\e[01;35m\h\e[00;36m:\[\e[33m\]\W\[\e[36m\]]\[\e[00m\]\$ '
138
+		PS1='\[\e[36m\][$(date +%H:%M) \u@\[\e[01;35m\]\h\[\e[00;36m\]:\[\e[33m\]\W\[\e[36m\]]\[\e[00m\]\$ '
138 139
 	fi
139 140
 else
140 141
     PS1='[$(date +%H:%M) \u@\h:\W]\$ '
... ...
@@ -146,7 +147,7 @@ PS1="${debian_chroot:+($debian_chroot)}$PS1"
146 147
 
147 148
 
148 149
 # Enable colors for man pages (adapt colors as needed)
149
-if [ "$color_prompt" = yes ]
150
+if [[ "$color_prompt" == "yes" ]]
150 151
 then
151 152
 	export LESS_TERMCAP_mb=$'\e[01;31m'    # blink start
152 153
 	export LESS_TERMCAP_md=$'\e[01;33m'    # bold start (if white bg: $'\e[01;31m')
... ...
@@ -161,7 +162,7 @@ unset color_prompt force_color_prompt
161 162
 
162 163
 
163 164
 # Enable color support of ls and grep and also add handy aliases
164
-if [ -x /usr/bin/dircolors ]
165
+if [[ -x /usr/bin/dircolors ]]
165 166
 then
166 167
     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
167 168
 
... ...
@@ -225,7 +226,7 @@ alias bye="exit"
225 226
 # ~/.bash_aliases, instead of adding them here directly.
226 227
 # See /usr/share/doc/bash-doc/examples in the bash-doc package.
227 228
 
228
-if [ -f ~/.bash_aliases ]
229
+if [[ -f ~/.bash_aliases ]]
229 230
 then
230 231
     . ~/.bash_aliases
231 232
 fi