-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
executable file
·225 lines (193 loc) · 6.81 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
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
#!/bin/sh
################################################
## Options
shopt -s autocd
shopt -s globstar # For recursive globbing with **/* etc
################################################
## History
# Don't put duplicate lines in the history. See bash(1) for more options
# Eternal bash history.
# ---------------------
# Undocumented feature which sets the size to "unlimited".
# http://stackoverflow.com/questions/9457233/unlimited-bash-history
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="[%F %T] "
# Change the file location because certain bash sessions truncate .bash_history file upon close.
# http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login
export HISTFILE=~/.bash_eternal_history
export HISTCONTROL=ignoredups
shopt -s histappend
################################################
## Prompt
source /usr/share/git/completion/git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWCOLORHINTS=
GIT_PS1_DESCRIBE_STYLE="branch"
GIT_PS1_SHOWUPSTREAM="auto git"
# prompt='__git_ps1 "\[\e[31m\]@\u\[\e[34m\] \w\n\[\e[30;43m\]" "\\\$\[\e[0m\] "'
prompt='__git_ps1 "\[\e[31m\]\u:\[\w\n\[\e[30;43m\]" "\\\$\[\e[0m\] "'
#
# # Hack to update history on every prompt
PROMPT_COMMAND="history -a; history -c; history -r; $prompt"
################################################
## Variables
# export SHELL="/bin/sh"
export EDITOR="vim"
export TERMINAL="urxvtcd"
export TERM="rxvt-unicode-256color"
export COLORTERM="rxvt-unicode-256color"
# gtk2 files for qt
export GTK2_RC_FILES="$HOME/.gtkrc-2.0"
# node local dir
export npm_config_prefix=~/.node_modules
export BROWSER=firefox
################################################
# Color
# export TERM="rxvt-256color"
if [ -x /usr/bin/dircolors ]; then
eval "`dircolors ~/.dircolors`"
alias ls='ls --color=auto'
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='colordiff' # requires colordiff package
alias pgrep='pgrep'
fi
################################################
## {{{ Aliases
## Dot cd
alias b='cd $OLDPWD'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias .......='cd ../../../../../..'
alias ........='cd ../../../../../../..'
alias .........='cd ../../../../../../../..'
## Shortcuts
alias vim='vim -p'
alias rc='ranger-cd'
alias rs='ranger --cmd="set column_ratios 0,5,0" --cmd="set draw_borders false" --cmd="set preview_files false" --cmd="set preview_directories false" --cmd="set vcs_aware true"' # alias xclip="xclip -selection c"
alias w='curl wttr.in/melbourne'
## Modified commands
alias more='less'
alias df='df -h'
alias du='du -c -h'
alias mkdir='mkdir -p -v'
alias ping='ping -c 5'
alias dmesg='dmesg -HL'
alias cp="cp -i" # confirm before overwriting something
# alias rm="rm -i" # confirm before overwriting something
# alias mv="mv -i" # confirm before overwriting something
alias reset="echo -ne '\033c'"
alias hide_cursor='echo -ne "\033[?25l"'
alias show_cursor='echo -ne "\033[?25h"'
alias feh='feh --auto-zoom --geometry 500x375 --sort filename'
## New commands
alias da='date "+%A, %B %d, %Y [%T]"' # print current date
alias du1='du --max-depth=1' # file size one folder deep
alias du2='du --max-depth=2' # file size two folders deep
alias h='history | grep' # requires an argument
alias openports='ss --all --numeric --processes --ipv4 --ipv6'
alias xp='xprop | grep "WM_WINDOW_ROLE\|WM_CLASS" && echo "WM_CLASS(STRING) = \"NAME\", \"CLASS\""'
## pacman
alias pe='expac -HM "%011m\t%-20n\t%10d" $( comm -23 <(pacman -Qqen|sort) <(pacman -Qqg base base-devel|sort) ) | sort -n'
## Keychain
#alias chain='eval $(keychain --eval --agents ssh -Q --quiet id_rsa)'
## ls
alias ll='ls -lh' # list detailed with human-readable sizes
alias la='ls -a' # list all files
alias lla='ls -lha' # list all detailed with human-readable sizes
alias lsd="ls /dev | grep sd" # list all drives
alias lr='ls -R' # recursive ls
alias lx='ll -BX' # sort by extension
alias lz='ll -rS' # sort by size
alias lt='ll -rt' # sort by date
alias lm='la | less' # pipe to less
alias q='exit'
alias pacman-disowned-dirs="comm -23 <(sudo find / \( -path '/dev' -o -path '/sys' -o -path '/run' -o -path '/tmp' -o -path '/mnt' -o -path '/srv' -o -path '/proc' -o -path '/boot' -o -path '/home' -o -path '/root' -o -path '/media' -o -path '/var/lib/pacman' -o -path '/var/cache/pacman' \) -prune -o -type d -print | sed 's/\([^/]\)$/\1\//' | sort -u) <(pacman -Qlq | sort -u)"
################################################ }}}
# Handy functions
# Start ranger if its not already open
r() {
if [ -z "$RANGER_LEVEL" ]
then
ranger
else
exit
fi
}
man() {
LESS_TERMCAP_md=$'\e[34m' \
LESS_TERMCAP_me=$'\e[0m' \
LESS_TERMCAP_se=$'\e[0m' \
LESS_TERMCAP_so=$'\e[33m' \
LESS_TERMCAP_ue=$'\e[0m' \
LESS_TERMCAP_us=$'\e[32m' \
command man "$@"
}
timer() {
reset
hide_cursor
date1=`date +%s`;
while true; do
echo -ne "\033[2K"; printf "\r"
echo -ne "$(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)";
sleep 0.1
done
show_cursor
}
countdown() {
reset
hide_cursor
cmd="clear && echo '$1 Done'"
while getopts ":m:" opt; do
case $opt in
m)
cmd="vlc ${HOME}/Music/Boredoms/Pop\ Tatari/boredoms\ -\ 03\ -\ hey\ bore\ hey.mp3"
shift
;;
esac
done
IFS=: read -r m s <<<$1
date1=$((`date +%s` + m * 60 + s));
while [ "$date1" -ne `date +%s` ]; do
echo -ne "\033[2K"; printf "\r"
echo -ne "$(date -u --date @$(($date1 - `date +%s`)) +%M:%S)";
sleep 1
done
eval $cmd
show_cursor
}
################################################
## Apps that integrate with the cli
# Rbenv
# eval "$(rbenv init -)"
# Fasd
eval "$(fasd --init auto)"
fasd_cache="$HOME/.fasd-init-bash"
if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then
fasd --init posix-alias bash-hook bash-ccomp bash-ccomp-install >| "$fasd_cache"
fi
source "$fasd_cache"
unset fasd_cache
# SSH keychain
. ~/.keychain/$HOSTNAME-sh
# ~/bin/set-bg-color
# Only execute if shell is interactive
if ! [ -z "$PS1" ]; then
# Fix bash keys. Why is this not loading automatically?
bind -f ~/.inputrc
# Ranger can be used to choose directories.
# source /usr/share/doc/ranger/examples/bash_automatic_cd.sh
fi
# Keychain
eval $(keychain --eval --agents ssh -Q --quiet id_rsa)
# added by travis gem
[ ! -s /home/raf/.travis/travis.sh ] || source /home/raf/.travis/travis.sh