Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 311 lines (262 sloc) 10.189 kb
39ffca0 @gabesoft bash and vim settings
authored
1 # .bashrc
2
bb9f68e @gabesoft terminal enhancements
authored
3 # --------------------------------------------------------------------------------
4 # options
5 # --------------------------------------------------------------------------------
6 set -o ignoreeof # Stop CTRL+D from logging me out.
7 set -o noclobber # Prevent overwriting files with >.
8 set -o notify # Notify of job termination.
9
10 shopt -s cdspell # Spell check path
11 shopt -s checkhash # Check program exists before executing.
12 shopt -s checkwinsize # Wrap lines correctly after resizing terminal.
13 shopt -s cmdhist # Remember multiline commands in history.
14 shopt -s extglob # Use extended pattern matching.
15 shopt -s histappend # Append to the history file.
16 shopt -s histreedit # Allow re-editing of a failed substitution.
17 shopt -s histverify # Don't execute retrieved history immediately; allow editing.
18 shopt -s lithist # Don't reformat multi-line cmd into one line with semicolons.
19
20 # history
21 export HISTCONTROL=ignoredups
f736ae6 @gabesoft cron update
authored
22
bb9f68e @gabesoft terminal enhancements
authored
23 # bash
24 bind "set completion-ignore-case on"
25 bind "set bell-style none"
26 bind "set show-all-if-ambiguous on"
27
28 # --------------------------------------------------------------------------------
286a6a1 @gabesoft os specific updates
authored
29 # platform
bb9f68e @gabesoft terminal enhancements
authored
30 # --------------------------------------------------------------------------------
286a6a1 @gabesoft os specific updates
authored
31 platform='unkown'
32 unamestr=`uname`
33
34 if [[ "$unamestr" == "Linux" ]]; then
35 platform='linux'
36 elif [[ "$unamestr" == "Darwin" ]]; then
37 platform='mac'
38 fi
39
bb9f68e @gabesoft terminal enhancements
authored
40 [[ "$TERM" != 'dumb' ]] && use_color='true' || use_color='false'
41 [[ "$use_color" == 'true' ]] && {
42 [[ "$(which dircolors)" ]] && use_color_gnu='true' || use_color_bsd='true'
43 }
44
45 # --------------------------------------------------------------------------------
46 # aliases
47 # --------------------------------------------------------------------------------
48
49 # alias = list all aliases
50 # cd = navigate home
51 # cd - = navigate to previous folder
52
f736ae6 @gabesoft cron update
authored
53 #navigation
54 alias ..='cd ..'
55 alias ...='cd .. ; cd ..'
daa1b3a @gabesoft aliases
authored
56 alias ....='cd .. ; cd .. ; cd ..'
286a6a1 @gabesoft os specific updates
authored
57 alias cdd='cd -' # go to previous directory
58
59 # sudo
60 alias s='sudo'
60d6a7e @gabesoft added alias
authored
61 alias svisudo='sudo visudo' # edit the sudoers file
39ffca0 @gabesoft bash and vim settings
authored
62
63 # delete
6ef78e8 @gabesoft added jslint
authored
64 alias ri='rm -i'
fbcbfa7 @gabesoft javascript indentation
authored
65 alias rf='rm -fv'
66 alias rr='rm -fv -r'
286a6a1 @gabesoft os specific updates
authored
67 alias srm='sudo rm -i'
fbcbfa7 @gabesoft javascript indentation
authored
68 alias srf='sudo rm -fv'
69 alias srr='sudo rm -fv -r'
39ffca0 @gabesoft bash and vim settings
authored
70
71 # copy move
daa1b3a @gabesoft aliases
authored
72 alias cpi='cp -i'
73 alias cri='cp -iR'
1e45d59 @gabesoft settings
authored
74 alias cpf='cp -f'
75 alias crf='cp -fR'
39ffca0 @gabesoft bash and vim settings
authored
76 alias mv='mv -i'
286a6a1 @gabesoft os specific updates
authored
77 alias scp='sudo cp -i'
78 alias scr='sudo cp -iR'
79 alias smv='sudo mv -i'
39ffca0 @gabesoft bash and vim settings
authored
80
bb9f68e @gabesoft terminal enhancements
authored
81 # ls family
e097586 @gabesoft bash aliases
authored
82 alias la='ls -hAF' # show all files
83 alias lA='ls -lhAFT' # show all files (extended)
e98892b @gabesoft more aliases
authored
84 alias la1='ls -hAF */' # show all files and folders with first level contents
85 alias lA1='ls -lhAFT */' # show all files and folders with first level contents (extended)
86 alias la2='ls -hAF */*/' # show all files and folders with second level contents
87 alias lA2='ls -lhAFT */*/' # show all files and folders with second level contents (extended)
88
e097586 @gabesoft bash aliases
authored
89 alias ll='ls -F' # show files
90 alias lL='ls -lhFT' # show files (extended)
70d3dc6 @gabesoft aliases
authored
91 alias ll1='ls -F */' # show files and folders with first level contents
92 alias lL1='ls -lhFT */' # show files and folders with first level contents (extended)
93 alias ll2='ls -F */*/' # show files and folders with second level contents
94 alias lL2='ls -lhFT */*/' # show files and folders with second level contents (extended)
e097586 @gabesoft bash aliases
authored
95
96 alias lz='ls -lhS' # show files sorted by size
97 alias lZ='ls -lhSA' # show all files sorted by size
98
99 alias lt='ls -lht' # show files sorted by time (most recent first)
100 alias lT='ls -lhtA' # show all files sorted by time (most recent first)
101
102 alias lr='ls -lhR' # show files recursive
103 alias lR='ls -lhRA' # show files recursive (include hidden)
104
105 alias lf='ls -l | grep -v "^d"' # show only files
106 alias lF='ls -Al | grep -v "^d"' # show only files (include hidden)
107
108 alias ldir='ls -l | grep "^d"' # show only directories
109 alias lDir='ls -Al | grep "^d"' # show only directories (include hidden)
bb9f68e @gabesoft terminal enhancements
authored
110
ba9038f @gabesoft git aliases
authored
111 # git
112 alias gad='git ad'
113 alias galias='git alias'
114 alias gbr='git br'
115 alias gca='git ca'
116 alias gcc='git cc'
117 alias gccc='git ccc'
118 alias gcf='git cf'
119 alias gch='git ch'
120 alias gci='git ci'
121 alias gco='git co'
122 alias gdf='git df'
123 alias gdm='git dm'
124 alias gds='git ds'
125 alias gdv='git dv'
126 alias gfw='git fw'
127 alias ggb='git gb'
128 alias glast='git last'
129 alias gld='git ld'
130 alias glf='git lf'
131 alias glg='git lg'
132 alias glo='git lo'
133 alias glr='git lr'
134 alias gls='git ls'
135 alias glt='git lt'
136 alias gmg='git mg'
137 alias gms='git ms'
138 alias gph='git ph'
e16b7ac @gabesoft bundle update + aliases
authored
139 alias gpr='git pr'
ba9038f @gabesoft git aliases
authored
140 alias gpm='git pm'
141 alias gpo='git po'
142 alias grf='git rf'
143 alias grh='git rh'
144 alias grr='git rr'
145 alias grs='git rs'
146 alias gso='git so'
147 alias gst='git st'
148 alias gsu='git su'
149 alias gundo='git undo'
1773ec9 @gabesoft vim + bash settings
authored
150
151 function delrec() {
9449214 @gabesoft vim + bash settings
authored
152 find . -name "$1" -print0 | xargs -0 rm -rfv ;
1773ec9 @gabesoft vim + bash settings
authored
153 }
154 alias delf='delrec' # delete files matching pattern in all subfolders recursively
155
bb9f68e @gabesoft terminal enhancements
authored
156 # paths
157 alias print-path='echo -e ${PATH//:/\\n}'
158 alias print-libpath='echo -e ${LD_LIBRARY_PATH//:/\\n}'
159
160 # curl
161 alias get='curl -C - -O'
162
163 # add colors for filetype recognition
164 [[ "$use_color_gnu" == 'true' ]] && alias ls='ls -hF --group-directories-first --color=auto'
165 [[ "$use_color_bsd" == 'true' ]] && alias ls='ls -G -F'
166
167 # mkdir make intermediate directories
168 alias mkdir='mkdir -p'
39ffca0 @gabesoft bash and vim settings
authored
169
5f862ba @gabesoft cron update
authored
170 # grep / find
171 alias g='grep -i'
172 alias f='find . -iname'
173
d1baa90 @gabesoft cron update
authored
174 # make a symbolic link
175 alias lk='ln -s'
176
5f862ba @gabesoft cron update
authored
177 # list the size of all folders and files
178 alias ducks='du -cks * | sort -rn|head -11'
179
180 # system log
181 alias systail='tail -f /var/log/system.log'
182
183 # show most used commands
184 alias profileme="history | awk '{print \$2}' | awk 'BEGIN{FS=\"|\"}{print \$1}' | sort | uniq -c | sort -n | tail -n 20 | sort -nr"
185
39ffca0 @gabesoft bash and vim settings
authored
186 # disk usage
187 alias df='df -h'
188
189 # tar
286a6a1 @gabesoft os specific updates
authored
190 alias untar='tar -xvzf'
191 alias suntar='sudo tar -xvzf'
192
f21620a @gabesoft java bash settings
authored
193 # jar (view jar contents)
194 alias vjar='jar -tvf'
195
286a6a1 @gabesoft os specific updates
authored
196 # sudo unzip
197 alias sunzip='sudo unzip'
198 alias sbunzip2='sudo bunzip2'
39ffca0 @gabesoft bash and vim settings
authored
199
9ea3afb @gabesoft cron update
authored
200 # execute permissions
201 alias exusr='chmod u+x' # current user
202 alias exall='chmod ugo+x' # all users
203
39ffca0 @gabesoft bash and vim settings
authored
204 # version
205 alias ver='cat /etc/redhat-release'
206
ae4046b @gabesoft cron update
authored
207 # list all colors
91369a4 @gabesoft cron update
authored
208 alias colors="set | egrep '^COLOR_\w*'"
39ffca0 @gabesoft bash and vim settings
authored
209
f21620a @gabesoft java bash settings
authored
210 # --------------------------------------------------------------------------------
211 # bookmarks
212 # --------------------------------------------------------------------------------
f736ae6 @gabesoft cron update
authored
213 # save bookmarks to folders
5f862ba @gabesoft cron update
authored
214 # save x = bookmarks the current directory as x
215 # cd x = navigates to the bookmarked path
216 # smarks = displays all bookmarks
217 # cmarks = clears all bookmarks
f736ae6 @gabesoft cron update
authored
218 if [ ! -f ~/.dirs ]; then # if doesn't exist, create it
bb9f68e @gabesoft terminal enhancements
authored
219 touch ~/.dirs
f736ae6 @gabesoft cron update
authored
220 fi
221
5f862ba @gabesoft cron update
authored
222 alias smarks='cat ~/.dirs'
223 alias cmarks='rm -f ~/.dirs; touch ~/.dirs'
f736ae6 @gabesoft cron update
authored
224 save (){
bb9f68e @gabesoft terminal enhancements
authored
225 command sed "/!$/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; echo "$@"=\"`pwd`\" >> ~/.dirs; source ~/.dirs ;
f736ae6 @gabesoft cron update
authored
226 }
227 source ~/.dirs # Initialization for the above 'save' facility: source the .sdirs file
228 shopt -s cdable_vars # set the bash option so that no '$' is required when using the above facility
229
bb9f68e @gabesoft terminal enhancements
authored
230 # --------------------------------------------------------------------------------
c227737 @gabesoft bash prompt fixes
authored
231 # prompt: show git branch and status
bb9f68e @gabesoft terminal enhancements
authored
232 # --------------------------------------------------------------------------------
c227737 @gabesoft bash prompt fixes
authored
233 function _git_prompt() {
234 local git_status="`git status -unormal 2>&1`"
235 if ! [[ "$git_status" =~ Not\ a\ git\ repo ]]; then
236 if [[ "$git_status" =~ nothing\ to\ commit ]]; then
127d54a @gabesoft terminal colors + other settings
authored
237 local branch_color=$COLOR_BLUE
c227737 @gabesoft bash prompt fixes
authored
238 elif [[ "$git_status" =~ nothing\ added\ to\ commit\ but\ untracked\ files\ present ]]; then
239 local branch_color=$COLOR_PURPLE
240 else
241 local branch_color=$COLOR_RED
242 fi
243 if [[ "$git_status" =~ On\ branch\ ([^[:space:]]+) ]]; then
244 branch=${BASH_REMATCH[1]}
245 else
246 # Detached HEAD. (branch=HEAD is a faster alternative.)
247 branch="(`git describe --all --contains --abbrev=4 HEAD 2> /dev/null ||
248 echo HEAD`)"
249 fi
127d54a @gabesoft terminal colors + other settings
authored
250 echo -n '\['"$COLOR_BLUE"'\](''\['"$branch_color"'\]'"$branch"'\['"$COLOR_BLUE"'\])'
c227737 @gabesoft bash prompt fixes
authored
251 fi
252 }
253 function _prompt_command() {
ff77bcd @gabesoft prompt fixes
authored
254 PS1="\[${COLOR_BROWN}\]\w `_git_prompt`\[${COLOR_RED}\]> \[${COLOR_NC}\]"
c227737 @gabesoft bash prompt fixes
authored
255 }
256 PROMPT_COMMAND=_prompt_command
5f862ba @gabesoft cron update
authored
257
bb9f68e @gabesoft terminal enhancements
authored
258 # --------------------------------------------------------------------------------
91369a4 @gabesoft cron update
authored
259 # colors
bb9f68e @gabesoft terminal enhancements
authored
260 # --------------------------------------------------------------------------------
91369a4 @gabesoft cron update
authored
261
262 # Black 0;30 Dark Gray 1;30
263 # Blue 0;34 Light Blue 1;34
264 # Green 0;32 Light Green 1;32
265 # Cyan 0;36 Light Cyan 1;36
266 # Red 0;31 Light Red 1;31
267 # Purple 0;35 Light Purple 1;35
268 # Brown 0;33 Yellow 1;33
269 # Light Gray 0;37 White 1;37
5f862ba @gabesoft cron update
authored
270
bb9f68e @gabesoft terminal enhancements
authored
271 #export CLICOLOR=1
272 #export TERM=xterm-color
286a6a1 @gabesoft os specific updates
authored
273
bb9f68e @gabesoft terminal enhancements
authored
274 [[ "$use_color_gnu" == 'true' ]] && eval $(dircolors $HOME/.dir_colors)
ff77bcd @gabesoft prompt fixes
authored
275 [[ "$use_color_gnu" == 'true' ]] && export LS_COLORS='di=0;36:fi=0;37:ln=0;35:pi=5:so=5:bd=5:cd=5:or=31:mi=1:ex=0;31:*.rb=90'
bb9f68e @gabesoft terminal enhancements
authored
276 [[ "$use_color_bsd" == 'true' ]] && export CLICOLOR=1
277 [[ "$use_color_bsd" == 'true' ]] && export LSCOLORS=Gxfxcxdxbxegedabagacad
39ffca0 @gabesoft bash and vim settings
authored
278
279 export COLOR_NC='\033[0m' # No Color
280 export COLOR_WHITE='\033[1;37m'
281 export COLOR_BLACK='\033[0;30m'
282 export COLOR_BLUE='\033[0;34m'
283 export COLOR_LIGHT_BLUE='\033[1;34m'
284 export COLOR_GREEN='\033[0;32m'
285 export COLOR_LIGHT_GREEN='\033[1;32m'
286 export COLOR_CYAN='\033[0;36m'
287 export COLOR_LIGHT_CYAN='\033[1;36m'
288 export COLOR_RED='\033[0;31m'
289 export COLOR_LIGHT_RED='\033[1;31m'
290 export COLOR_PURPLE='\033[0;35m'
291 export COLOR_LIGHT_PURPLE='\033[1;35m'
292 export COLOR_BROWN='\033[0;33m'
293 export COLOR_YELLOW='\033[1;33m'
294 export COLOR_GRAY='\033[1;30m'
295 export COLOR_LIGHT_GRAY='\033[0;37m'
296
286a6a1 @gabesoft os specific updates
authored
297 export COLOR_BG_NC='\033[49m'
298 export COLOR_BG_LIGHT_GRAY='\033[47m'
299 export COLOR_BG_PURPLE='\033[45m'
300 export COLOR_BG_RED='\033[41m'
301 export COLOR_BG_GREEN='\033[42m'
302 export COLOR_BG_YELLOW='\033[43m'
303 export COLOR_BG_BLUE='\033[44m'
304 export COLOR_BG_CYAN='\033[46m'
305
127d54a @gabesoft terminal colors + other settings
authored
306 echo -e "${COLOR_RED}kernel info: " `uname -smr`
92b6ed4 @gabesoft cron update
authored
307 echo -e "${COLOR_BROWN}`bash --version`"
127d54a @gabesoft terminal colors + other settings
authored
308 echo -ne "${COLOR_GREEN}uptime: "; uptime
309 echo -ne "${COLOR_GREEN}server time is: "; date
92b6ed4 @gabesoft cron update
authored
310 echo -ne "${COLOR_NC}"
Something went wrong with that request. Please try again.