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