-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc
More file actions
174 lines (160 loc) · 4.36 KB
/
bashrc
File metadata and controls
174 lines (160 loc) · 4.36 KB
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
#
# ~/.bashrc
#
# vim: fdm=marker
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
shopt -q -s cdspell dirspell checkwinsize no_empty_cmd_completion cmdhist checkhash histappend
# simple alias {{{
alias cd..='cd ..'
if [[ -x $(which vi 2>/dev/null) ]]; then
echo >> /dev/null
elif [[ -x $(which nvim 2>/dev/null) ]]; then
alias vi='nvim'
elif [[ -x $(which vim 2>/dev/null) ]]; then
alias vi='vim'
fi
alias tree='tree -C'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# add '.' at the end on freebsd
alias gr='egrep -nr'
alias grc='egrep -nr --include=*.{c,cc,cpp,s,S,ld,cxx,C,h,hh,hpp,py,hs,java,sh,pl,tex,go,rs}'
alias du0='du -h -d 0'
alias du1='du -h -d 1'
alias dfh='df -h'
alias remake='make -B'
alias pull='git pull'
alias push='git push'
alias fetch='git fetch'
alias commit='git commit'
alias tiga='tig --all'
alias pri='perf report -i'
alias uptime='uptime -p'
case "$(uname -s)" in
Linux)
alias ls='ls --color=auto'
alias ll='ls -alhF --time-style=long-iso'
alias lt='ls -lrhFt --time-style=long-iso'
alias lz='ls -lrhFS --time-style=long-iso'
alias freeh='free -h'
alias utags='ctags -R . /usr/include'
alias mtags='ctags -R . /usr/lib/modules/$(uname -r)/build'
;;
Darwin)
alias gr='gegrep --color=auto -nr'
alias grc='gegrep --color=auto -nr --include=*.{c,cc,cpp,s,S,ld,cxx,C,h,hh,hpp,py,hs,java,sh,pl,tex,go,rs}'
alias ls='gls --color=auto'
alias ll='gls --color=auto -alhF --time-style=long-iso'
alias lt='gls --color=auto -lrhFt --time-style=long-iso'
alias lz='gls --color=auto -lrhFS --time-style=long-iso'
alias make='gmake'
;;
FreeBSD)
alias ls='ls -G'
alias ll='ls -alhF -G -D "%F %H:%M"'
alias lt='ls -lrhFt -G -D "%F %H:%M"'
alias lz='ls -lrhFS -G -D "%F %H:%M"'
alias ctags='uctags'
alias make='gmake'
alias tput='/usr/local/bin/tput'
;;
*)
;;
esac
# }}}
# color-man {{{
man()
{
LESS_TERMCAP_mb=$'\e[1;35m' \
LESS_TERMCAP_md=$'\e[1;34m' \
LESS_TERMCAP_so=$'\e[01;103m\e[1;30m' \
LESS_TERMCAP_se=$'\e[0m' \
LESS_TERMCAP_us=$'\e[1;4;31m' \
LESS_TERMCAP_ue=$'\e[0m' \
LESS_TERMCAP_me=$'\e[0m' \
command man "$@"
}
# }}} color-man
# exports {{{
if [[ -z $BASHRC_LOADED ]]; then
if [[ -d "${HOME}/.local/bin" ]]; then
if [[ -z ${PATH} ]]; then
PATH=${HOME}/.local/bin
else
PATH=${HOME}/.local/bin:${PATH}
fi
export PATH
fi
prog=${HOME}/program
if [[ -d "${prog}" ]]; then
if [[ -f "${prog}/.wl" ]]; then
wl=$(cat "${prog}/.wl")
else
wl=$(ls ${prog})
fi # white-list
for home in ${wl}; do
ph=${prog}/${home}
if [[ -d "${ph}" ]]; then
for bd in bin sbin; do
if [[ -d "${ph}/${bd}" ]]; then
if [[ -z ${PATH} ]]; then
PATH=${ph}/${bd}
else
PATH=${ph}/${bd}:${PATH}
fi
fi
done
for ld in lib lib64; do
if [[ -d "${ph}/${ld}" ]]; then
if [[ -z ${LD_LIBRARY_PATH} ]]; then
LD_LIBRARY_PATH=${ph}/${ld}
else
LD_LIBRARY_PATH=${ph}/${ld}:${LD_LIBRARY_PATH}
fi
#if [[ -z ${LIBRARY_PATH} ]]; then
# LIBRARY_PATH=${ph}/${ld}
#else
# LIBRARY_PATH=${ph}/${ld}:${LIBRARY_PATH}
#fi
fi
done
fi
done
export PATH
export LD_LIBRARY_PATH
#export LIBRARY_PATH
fi # program
[[ -f ~/.bashrc.local1 ]] && . ~/.bashrc.local1
export HISTCONTROL=ignoreboth:erasedups
export HISTSIZE=10000
export HISTFILESIZE=20000
export HISTIGNORE='&'
export EDITOR='vim'
export PROMPT_COMMAND='history -a'
export BASHRC_LOADED=y
fi # BASHRC_LOADED
# }}}
# PS1 {{{
if [[ -x $(which tput 2>/dev/null) ]]; then
# username
PS_u="$(tput bold)$(tput smul)$(tput setab 0)$(tput setaf 2)\\u"
# tmux (see man page FORMATS for variable names)
[[ -n ${TMUX} ]] && PS_m="$(tput setaf 7)@$(tput setaf 6)"'$(tmux display-message -p "#{window_index}/#{session_windows}:#{pane_index}/#{window_panes}")'
# hostname
PS_h="$(tput setaf 7)@$(tput setaf 5)\\h"
# time
PS_t="$(tput setaf 7)@$(tput setaf 6)\\t"
# wd
PS_d="$(tput setaf 7):$(tput setaf 3)\\w$(tput sgr0) "
# working dir info
[[ -z $PS_w ]] && [[ -x $(which ps1git 2>/dev/null) ]] && PS_w='$(ps1git)'
# the prompt $
PS_p="\n\\$ "
PS1="${PS_u}${PS_m}${PS_h}${PS_t}${PS_d}${PS_w}${PS_p}"
else
PS1="\\u@\\h@\\t:\\w\n\\$ "
fi
# }}} PS1
[[ -f ~/.bashrc.localn ]] && . ~/.bashrc.localn