-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.bashrc
More file actions
221 lines (209 loc) · 6.21 KB
/
Copy path.bashrc
File metadata and controls
221 lines (209 loc) · 6.21 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
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
# Bash interactive settings
#
# Maintainer: DeaR <nayuri@kuonn.mydns.jp>
# Last Change: 15-Nov-2016.
# License: MIT License {{{
# Copyright (c) 2013 DeaR <nayuri@kuonn.mydns.jp>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the
# following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
# OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
# THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# }}}
#------------------------------------------------------------------------------
# If not running interactively, don't do anything: {{{
[[ $- != *i* ]] && return
#}}}
#------------------------------------------------------------------------------
# Terminal Multiplexer: {{{
if [[ -z ${TMUX} && -z ${STY} ]]; then
if type tmux >/dev/null 2>&1; then
if tmux ls >/dev/null 2>&1; then
if hash cho; then
REPLY=$(tmux ls | cho | sed "s/:.*//")
elif hash iselect; then
REPLY=$(tmux ls | iselect -a -f | sed "s/:.*//")
else
tmux ls
read -p "Select attach: " REPLY
fi
[[ -n ${REPLY} ]] && tmux a -t $REPLY && exit
fi
tmux && exit
elif type screen >/dev/null 2>&1; then
if [[ $(screen -ls | wc -l) -ge 3 ]]; then
if hash cho; then
REPLY=$(screen -ls | sed -n "/^\t/p" | cho | awk '{print $1}')
elif hash iselect; then
REPLY=$(screen -ls | sed -n "/^\t/p" | iselect -a -f | awk '{print $1}')
else
screen -ls
read -p "Select attach: " REPLY
fi
[[ -n ${REPLY} ]] && screen -rx $REPLY && exit
fi
screen && exit
fi
else
_INIT_TITLE=0
function _lastcmd {
if [[ ${_INIT_TITLE} -ne 0 ]]; then
echo -ne "\ek$(history 1 | awk '{if($4=="sudo")print $5;else print $4}')\e\\"
fi
_INIT_TITLE=1
}
PROMPT_COMMAND="_lastcmd;${PROMPT_COMMAND}"
fi
#}}}
#------------------------------------------------------------------------------
# Option: {{{
shopt -s cdspell
shopt -s checkhash
shopt -s checkwinsize
shopt -s cmdhist
shopt -s dotglob
shopt -s extglob
shopt -s no_empty_cmd_completion
shopt -s nocaseglob
umask 022
ulimit -c 0
#}}}
#------------------------------------------------------------------------------
# Option For 4.x: {{{
if [[ ${BASH_VERSINFO[0]} -ge 4 ]]; then
shopt -s autocd
shopt -s dirspell
shopt -s globstar
fi
#}}}
#------------------------------------------------------------------------------
# Emacs Like Keybind: {{{
set -o emacs
#}}}
#------------------------------------------------------------------------------
# Prompt: {{{
PS1="\[\e[32;1m\]\u@\h \[\e[33;1m\]\w\[\e[m\]\n\$ "
IGNOREEOF=1
#}}}
#------------------------------------------------------------------------------
# History: {{{
HISTFILE="${XDG_CACHE_HOME}/bash_history"
HISTSIZE="100000"
HISTFILESIZE="100000"
HISTCONTROL="ignoredups"
HISTTIMEFORMAT="%F %T "
if [[ ${BASH_VERSINFO[0]} -ge 4 ]]; then
function _histshare {
history -a
history -c
history -r
}
PROMPT_COMMAND="_histshare;${PROMPT_COMMAND}"
fi
#}}}
#------------------------------------------------------------------------------
# Completion: {{{
if [[ -f ${HOME}/.bash.d/bash_completion ]]; then
. "${HOME}/.bash.d/bash_completion"
elif [[ -f /usr/local/etc/bash_completion ]]; then
. "/usr/local/etc/bash_completion"
elif [[ -f /etc/bash_completion ]]; then
. "/etc/bash_completion"
fi
#}}}
#-----------------------------------------------------------------------------
# LS: {{{
if type grep >/dev/null 2>&1; then
alias ls="ls --color=auto --show-control-chars"
alias ll="ls -alF"
function lld {
ll --color $@ | grep --color=never '/$'
}
function llf {
ll --color $@ | grep --color=never -v '/$'
}
function lle {
ll --color $@ | grep --color=never '\*$'
}
function lls {
ll --color $@ | grep --color=never '\->'
}
fi
#}}}
#-----------------------------------------------------------------------------
# Alias: {{{
alias q="exit"
alias cls="clear"
if [[ -n ${EDITOR} ]]; then
alias e="${EDITOR}"
fi
if [[ -n ${PAGER} ]]; then
alias l="${PAGER}"
fi
if type head >/dev/null 2>&1; then
alias h="head"
fi
if type tailf >/dev/null 2>&1; then
alias t="tailf"
elif type tail >/dev/null 2>&1; then
alias t="tail -f"
fi
if type gvim >/dev/null 2>&1; then
alias vi="gvim"
alias vim="gvim"
elif type vim >/dev/null 2>&1; then
alias vi="vim"
fi
if type hub >/dev/null 2>&1; then
alias git="hub"
fi
if type hg >/dev/null 2>&1; then
alias hg="hg --config pager.pager='$HGPAGER'"
fi
if type grep >/dev/null 2>&1; then
alias grep="grep --color"
fi
if type head >/dev/null 2>&1; then
alias diff="colordiff"
fi
if type less >/dev/null 2>&1; then
alias ltail="less +F -L"
fi
#}}}
#------------------------------------------------------------------------------
# Stty: {{{
if type stty >/dev/null 2>&1; then
stty start undef
stty stop undef
fi
#}}}
#-----------------------------------------------------------------------------
# Post Init: {{{
if [[ -f ${HOME}/.bashrc_local ]]; then
. "${HOME}/.bashrc_local"
elif [[ -f ${HOME}/.bash.d/bashrc_local ]]; then
. "${HOME}/.bash.d/bashrc_local"
elif [[ -f ${HOME}/.bashrc_local.sh ]]; then
. "${HOME}/.bashrc_local.sh"
elif [[ -f ${HOME}/.bash.d/bashrc_local.sh ]]; then
. "${HOME}/.bash.d/bashrc_local.sh"
elif [[ -f ${HOME}/.bashrc_local.bash ]]; then
. "${HOME}/.bashrc_local.bash"
elif [[ -f ${HOME}/.bash.d/bashrc_local.bash ]]; then
. "${HOME}/.bash.d/bashrc_local.bash"
fi
# }}}