-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy path.bashrc
85 lines (72 loc) · 1.92 KB
/
.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
# History control
HISTCONTROL=ignoredups:ignorespace
HISTSIZE=100000
HISTFILESIZE=2000000
shopt -s histappend
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
alias grep='grep --color=auto'
alias tnn="cd ~/src/github.com/tomnomnom"
alias :q="exit"
alias follow="tail -f -n +1"
# COLOURS! YAAAY!
export TERM=xterm-256color
# Obviously.
export EDITOR=/usr/bin/vim
# Personal binaries
export PATH=${PATH}:~/bin:~/.local/bin:~/etc/scripts
# I'd quite like for Go to work please.
export PATH=${PATH}:/usr/local/go/bin
export GOPATH=~
# Open all modified files in vim tabs
function vimod {
vim -p $(git status -suall | awk '{print $2}')
}
# Open files modified in a git commit in vim tabs; defaults to HEAD. Pop it in your .bashrc
# Examples:
# virev 49808d5
# virev HEAD~3
function virev {
commit=$1
if [ -z "${commit}" ]; then
commit="HEAD"
fi
rootdir=$(git rev-parse --show-toplevel)
sourceFiles=$(git show --name-only --pretty="format:" ${commit} | grep -v '^$')
toOpen=""
for file in ${sourceFiles}; do
file="${rootdir}/${file}"
if [ -e "${file}" ]; then
toOpen="${toOpen} ${file}"
fi
done
if [ -z "${toOpen}" ]; then
echo "No files were modified in ${commit}"
return 1
fi
vim -p ${toOpen}
}
source ~/etc/git-prompt.sh
# 'Safe' version of __git_ps1 to avoid errors on systems that don't have it
function gitPrompt {
command -v __git_ps1 > /dev/null && __git_ps1 " (%s)"
}
# Colours
txtgrn='\[\e[0;32m\]' # Green
txtpur='\[\e[0;35m\]' # Purple
txtwht='\[\e[0;37m\]' # White
# Prompt colours
atC="${txtpur}"
nameC="${txtpur}"
hostC="${txtpur}"
pathC="${txtgrn}"
gitC="${txtpur}"
pointerC="${txtgrn}"
normalC="${txtwht}"
# Patent Pending Prompt
export PS1="${nameC}\u${atC}@${hostC}\h:${pathC}\w${gitC}\$(gitPrompt)${pointerC}▶${normalC} "
# Local settings go last
if [ -f ~/.localrc ]; then
source ~/.localrc
fi