-
Notifications
You must be signed in to change notification settings - Fork 1
/
bashrc
147 lines (119 loc) · 3.61 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
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
# ~/.bashrc
# If not running interactively, don't do anything
[[ "$-" != *i* ]] && return
# Bash completion
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# Conditionals
_iscygwin=0
[[ $( uname -s ) == *"CYGWIN"* ]] && _iscygwin=1
_isroot=0
[[ $UID -eq 0 ]] && _isroot=1
_color=0
[[ "$TERM" =~ xterm_color ]] && _color=1
# Umask
umask 022
# History
export HOSTCONTROL=ignoredups:ignorespace
export HISTSIZE=9999
export HISTFILESIZE=9999
# Shelloptions (shopt)
shopt -s cdspell # Autocorrect mistyped directory
shopt -s autocd # Automatically add cd before known dir names
shopt -s dirspell
shopt -s globstar
shopt -s progcomp
shopt -s extglob
shopt -s histappend # Append history instead of overwriting file
shopt -s checkwinsize # Check window size after each command
shopt -s no_empty_cmd_completion # No empty completion
shopt -s cmdhist
shopt -s histappend histreedit histverify
# Misc Exports
export HOSTCONTROL=ignoredups:ignorespace
export HISTSIZE=100000
export HISTFILESIZE=200000
export HISTIGNORE='&:ls:ll:la:cd:exit:clear:history'
export PAGER=less
export EDITOR=vim
export PATH="~/bin:~/.scripts:$PATH"
export TIME_STYLE=long-iso
# Mintty
bind -r '\C-s'
stty -ixon
# Xorg/X
export DISPLAY=:0.0
# Prompt
source ~/.bash_prompt
# Aliases
alias browse='explorer $(cygpath --windows $(pwd))'
# Standard tools
alias du='du -c -h'
alias df='df -h'
alias less='less -r' # raw control characters
alias grep='grep --color' # show differences in colour
alias egrep='egrep --color=auto' # show differences in colour
alias fgrep='fgrep --color=auto' # show differences in colour
alias diff='colordiff'
alias ls='ls -h --color=auto --hide="*.pyc"'
alias lx='ls -lXB' # Sort by extensions.
alias lk='ls -lSr' # Sort by size, biggest last.
alias lt='ls -ltr' # Sort by date, most recent last.
alias lc='ls -ltcr' # Sort by/show change time, most recent last.
alias lu='ls -ltur' # Sort by/show access time, most recent last.
alias ll='ls -lv --group-directories-first'
alias lr='ll -R'
alias la='ll -a'
alias svim='sudo vim'
alias root='sudo su'
alias vi='vim'
alias tmux="tmux -u"
alias ..='cd ..'
# Search tool
alias ags='ag --color-match="31;40" -U -S -G "[.](c|h|inc|def|txt|ldf|asm)$"'
alias agd='ag --color-match="31;40" -U -S -G "[.](def)$"'
# At work
alias ct="cleartool"
# Very quick
alias a='ag --color-match="31;40" -U -S'
alias g="git g"
alias l="ls -h --color=auto"
alias p="ipython --profile=etel"
alias t="task"
alias v="vim"
alias chrome="'/cygdrive/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'"
alias todo="vim ~/.notes/todo.md"
alias note="vim ~/.notes/notes.md"
# WSL
alias e='explorer.exe .'
# Easily extract any kind of atchives.
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjvf $1 ;;
*.tar.gz) tar xzvf $1 ;;
*.bz2) bzip2 -d $1 ;;
*.rar) unrar2dir $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip2dir $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*.ace) unace x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
bcomp() {
a="$1"
b="$2"
aw="$(cygpath -w $a)"
bw="$(cygpath -w $b)"
"/cygdrive/c/Program Files (x86)/Beyond Compare 4/Bcomp.exe" $aw $bw /lefttitle=$a /righttitle=$b
}
[ -f ~/.fzf.bash ] && source ~/.fzf.bash