-
Notifications
You must be signed in to change notification settings - Fork 1
/
bashrc
119 lines (101 loc) · 2.46 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
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
## Set some vars
SELF=$(test -L "$BASH_SOURCE" && readlink -n "$BASH_SOURCE" || echo "$BASH_SOURCE")
BASEDIR=$(dirname "$SELF")
EDITOR=vim
VISUAL=$EDITOR
export EDITOR VISUAL
export CLICOLOR=1
export LESS="FRSXi"
export RLWRAP_HOME="$BASEDIR"/rlwrap
export PYTHONSTARTUP="$BASEDIR"/pystartup.py
## History Control
HISTSIZE=20000
HISTCONTROL=ignoreboth
HISTIGNORE="?:??"
shopt -s autocd cdspell dirspell
shopt -s extglob globstar
shopt -s cmdhist histappend
shopt -s no_empty_cmd_completion
shopt -s huponexit checkjobs
shopt -s direxpand
## Aliases
alias ..='cd ..'
alias la='ls -a'
alias ll='ls -l'
alias lla='ls -la'
alias lld='ls -ld'
alias cx='chmod +x'
alias dfh='df -H'
alias grep='grep --colour'
alias mkdir='mkdir -p'
alias psg='ps aux |grep -i'
alias sude='sudo -e'
alias serve='python -m SimpleHTTPServer'
alias tree='tree -C'
alias trls='tree -C |less'
alias fnls='find . |less'
alias k2='kill -2'
alias bc='bc -ql'
alias gdb='gdb -q'
alias suniq='sort |uniq'
## Git aliases
alias gd='git diff'
alias ga='git add'
alias gst='git status --short --branch'
alias sqlite3='sqlite3 -column -header'
cf() {
cd *$1*/
}
md() {
mkdir -p "$1" && cd "$1"
}
swp() {
local tmp=$(mktemp -u .XXXXX)
mv "$1" $tmp
mv "$2" "$1"
mv $tmp "$2"
}
vact() {
source $1/bin/activate
}
extract-audio() {
local input="$1"
local output="${input%.*}.mp3"
ffmpeg -i "$input" -c:a copy -vn "$output"
}
convert2mp3() {
local input="$1"
local output=${input%.*}.mp3
ffmpeg -i "$input" -ab 320k -map_metadata 0 "$output"
}
rm-bom() {
local input="$1"
tail -c +4 "$input" | sponge "$input"
}
## [Optional] Tools
source "$BASEDIR"/bash/z/z.sh
command -v lesspipe.sh >/dev/null && eval "$(SHELL=/bin/sh lesspipe.sh)"
command -v thefuck >/dev/null && eval "$(thefuck --alias)"
command -v fortune >/dev/null && fortune
command -v colordiff >/dev/null && alias diff='colordiff -u'
command -v direnv >/dev/null && eval "$(direnv hook bash)"
## rlwrap aliases
if command -v rlwrap >/dev/null; then
alias sbcl='rlwrap sbcl'
alias sml='rlwrap sml'
alias clj='rlwrap clj'
alias ocaml='rlwrap ocaml'
alias ocamldebug='rlwrap ocamldebug'
fi
## Source machine specific bashrc
if [[ -f "$HOME/.bashrc_local" ]]; then
source "$HOME/.bashrc_local"
fi
## Add hostname to PS1 if I am in an SSH session
if [[ -z "$SSH_TTY" ]]; then
PS1="\w $ "
else
PS1="[\u@\h \w]\$ "
fi