-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_bashrc
274 lines (216 loc) · 6.17 KB
/
dot_bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# .bashrc
#!/usr/bin/env bash
# ${HOME}/.bashrc: executed by bash(1) for non-login shells.
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
[[ $- != *i* ]] && return
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
############## BASH COMPLETION ################
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
############## HISTORY OPTIONS ################
# Don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# Append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=100000
HISTFILESIZE=2000000
# Save and reload history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
# bind the up and down arrow keys to search through Bash's history
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
############## GENERAL UI ################
force_color_prompt=yes
# Vim key-bindings
set -o vi
# Check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# Make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
############## INPUT ################
# correct minor spelling errors in cd
shopt -s cdspell
#include dotfiles in wildcard expansion, and match case-insensitively
shopt -s dotglob
shopt -s nocaseglob
############## SYSTEM ################
export PATH=$PATH:/usr/games/
############## FUNCITON ################
# Functions to aid git workflow
function ga() {
git-add $1
}
function gc() {
git commit -m "$*"
}
function revert() {
git reset --hard $1
}
# Useful unarchiver!
function extract() {
if [ -f $1 ]; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
function psg() {
if [ ! -z $1 ]; then
echo "Grepping for processes matching $1..."
ps aux | grep $1
else
echo "!! Need name to grep for"
fi
}
# Because I am a lazy bum, and this is
# surpisingly helpful..
function up() {
for i in $(seq 1 $1); do
cd ../
done
}
############## EXPORT ################
export PATH=$HOME/scripts:$HOME/.local/bin:/usr/local/bin:$PATH
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
export EDITOR='vim' ALTERNATE_EDITOR='vim'
# Bash History
export HISTCONTROL=$HISTCONTROL
export HISTIGNORE='&:clear:ls:cd:[bf]g:exit:[ t\]*'
# Bitbake Env settings
# export BBPATH=/stuff/maemo-angstrom:/stuff/build:/stuff/openembedded
# export PATH=/stuff/bitbake/bin:$PATH
# Proxy settings
#export http_proxy='127.0.0.1:5050'
#export https_proxy='127.0.0.1:5050'
#export ftp_proxy='127.0.0.1:5050'
export http_proxy=
export https_proxy=
export ftp_proxy=
############## ALIAS ################
# Cute shell shortcuts
alias ls='ls --sort=extension --color=auto'
alias ll='ls -lh'
alias lal='ls -alh'
alias la='ls -A'
alias pms='sudo pm-suspend'
alias psg='ps -A | grep'
alias smi='sudo make install'
alias l='ls -CF'
# Cool colors for man pages
alias man="TERMINFO=~/.terminfo TERM=mostlike LESS=C PAGER=less man"
# Enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# This one is to take care of make
# Give me a nice, distinguishable make output
alias make='clear && make'
alias m='make'
# Some more, to avoid mistakes
alias rm='rm -i'
#alias cp='cp -i'
#alias mv='mv -i'
# Git Commands
# Add and Commit are used as functions
alias gpo='git push origin master'
alias gp='git pull'
alias gs='git status'
alias gd='git diff'
alias gr='git reflog'
alias glf='git ls-files'
############## PROMPT ################
# Colours have names too. Stolen from Arch wiki
txtblk='\[\e[0;30m\]' # Black - Regular
txtred='\[\e[0;31m\]' # Red
txtgrn='\[\e[0;32m\]' # Green
txtylw='\[\e[0;33m\]' # Yellow
txtblu='\[\e[0;34m\]' # Blue
txtpur='\[\e[0;35m\]' # Purple
txtcyn='\[\e[0;36m\]' # Cyan
txtwht='\[\e[0;37m\]' # White
bldblk='\[\e[1;30m\]' # Black - Bold
bldred='\[\e[1;31m\]' # Red
bldgrn='\[\e[1;32m\]' # Green
bldylw='\[\e[1;33m\]' # Yellow
bldblu='\[\e[1;34m\]' # Blue
bldpur='\[\e[1;35m\]' # Purple
bldcyn='\[\e[1;36m\]' # Cyan
bldwht='\[\e[1;37m\]' # White
unkblk='\[\e[4;30m\]' # Black - Underline
undred='\[\e[4;31m\]' # Red
undgrn='\[\e[4;32m\]' # Green
undylw='\[\e[4;33m\]' # Yellow
undblu='\[\e[4;34m\]' # Blue
undpur='\[\e[4;35m\]' # Purple
undcyn='\[\e[4;36m\]' # Cyan
undwht='\[\e[4;37m\]' # White
bakblk='\[\e[40m\]' # Black - Background
bakred='\[\e[41m\]' # Red
badgrn='\[\e[42m\]' # Green
bakylw='\[\e[43m\]' # Yellow
bakblu='\[\e[44m\]' # Blue
bakpur='\[\e[45m\]' # Purple
bakcyn='\[\e[46m\]' # Cyan
bakwht='\[\e[47m\]' # White
txtrst='\[\e[0m\]' # Text Reset
# Prompt colours
nameC="${bldblu}"
# Red name for root
if [ "${UID}" -eq "0" ]; then
nameC="${bldred}"
fi
# Patent Pending Prompt
export PS1="${nameC}\u${txtwht}@${txtwht}\h ${bldwht}\w ${txtwht}%${txtwht} "
############## GIT ################
# Very useful for stash handling
function show-stash()
{
git stash show -p stash@{$1};
}
function stash-len()
{
git stash list | wc -l;
}
function drop-stash()
{
git stash drop stash@{$1};
}
alias ga='git add'
alias gb='git br'
alias gd='git diff'
alias gdc='git diff --cached'
alias gl='git log'
alias gp='git pull'
alias gs='git status'
alias gst='git stash'
alias gplo='git pull origin master'
alias gbv='git branch -vv'
# Useful when working on a branch and
# want to summarize changes against master
alias gdmno='git diff master --name-only'
# User specific aliases and functions