-
Notifications
You must be signed in to change notification settings - Fork 1
/
bashrc
148 lines (120 loc) · 3.88 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
148
# stuff {{{1
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
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=1000
HISTFILESIZE=2000
# 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)"
# enable programmable completion features
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
#}}}
# prompt statement {{{1
# change color of branch name
git_color() {
if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then
local color="${Cyan}"
# modified
git diff --no-ext-diff --quiet --exit-code || color="${Red}"
# staged
if git rev-parse --quiet --verify HEAD >/dev/null; then
git diff-index --cached --quiet HEAD -- || color="${IRed}"
fi
# stashed
git rev-parse --verify refs/stash >/dev/null 2>&1 && color="${Yellow}"
echo "$color"
fi
}
PS1='\[${Blue}\]\u \
\[$(echk_color)\]$(echk_random_face) \
\[$(git_color)\]$(__git_ps1 "%s ")\[${Yellow}\]\
$([ \j -gt 0 ] && echo "\j ")\[${White}\]\
\$\[${Color_Off}\] '
# PS1='\[${White}\]\$\[${Color_Off}\] '
# PS1="${Blue}\u@\h${Color_Off}:${Cyan}\w${White}❯❯${Color_Off} "
# PS1='C:${PWD////\\\\}> '
PS2='\[${White}\]\$\[${Color_Off}\] '
PROMPT_COMMAND="[ -d .git -o -f .sett ] && sett"
# basic {{{1
export EDITOR='vim'
# allow for color support in terminal
if [ "$TERM" == "xterm" ]; then
export TERM=xterm-256color
fi
export GPG_TTY=$(tty)
# load other files
source ~/bin/ED.sh
source ~/bin/echk
source ~/bin/colors.sh
source ~/bin/z.sh
# add dart's bin to PATH
if [ -d "/usr/lib/dart/bin" ] ; then
PATH="/usr/lib/dart/bin:$PATH"
fi
if [ -d "$HOME/code/dart/flutter/bin" ] ; then
PATH="$HOME/code/dart/flutter/bin:$PATH"
fi
# aliases {{{1
# better tab complete
bind '"\t":menu-complete'
# enable color support
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto -F'
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'
alias diff='diff --color=auto'
fi
# easily change back directories
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
# better ls-ing
alias ll='ls -alF'
alias la='ls -A'
# make these commands safer
alias mv='mv -i'
alias cp='cp -i'
alias ln='ln -i'
alias rm='rm -i'
# shortcuts
alias sb='source ~/.bashrc'
alias cmon='sudo "$BASH" -c "$(history -p !!)"'
alias emacs='emacs --no-window-system'
alias matlab='matlab -nodesktop'
alias old='tg old'
alias gdb='gdb -q'
alias db='gdb -q -ex run ./$(basename $PWD)' # TODO smart script to allow argument
alias v='valgrind --leak-check=full --show-leak-kinds=all'
alias gf='echo haha, you wish'
alias ytdlp='youtube-dl --extract-audio --audio-format mp3 -o "%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s"'
alias newline='echo >>'
alias term='tabbed -c st -w'
alias f='feh --force-aliasing --auto-zoom --auto-rotate --scale-down'
alias py='python3 -q'
alias exif='identify -verbose' # TODO only get exif info
alias todo='grep -RI TODO * --exclude-dir=public' # TODO use git grep if in git repo
alias gg='git grep --untracked'
alias dock-run='docker run -it --rm --detach-keys='ctrl-e,e' -v $PWD:$PWD -w $PWD'
alias fonts-reload='fc-cache -f -v'
#}}}