-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
275 lines (222 loc) · 7.9 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# to the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
# public domain worldwide. This software is distributed without any warranty.
# You should have received a copy of the CC0 Public Domain Dedication along
# with this software.
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
# ~/.bashrc: executed by bash(1) for interactive shells.
# The copy in your home directory (~/.bashrc) is yours, please
# feel free to customise it to create a shell
# environment to your liking. If you feel a change
# would be benifitial to all, please feel free to send
# a patch to the msys2 mailing list.
# User dependent .bashrc file
# If not running interactively, don't do anything
[[ "$-" != *i* ]] && return
# Shell Options
#
# See man bash for more options...
#
# Don't wait for job termination notification
set -o notify
#
# Don't use ^D to exit
# set -o ignoreeof
#
# Use case-insensitive filename globbing
shopt -s nocaseglob
#
# When changing directory small typos can be ignored by bash
# for example, cd /vr/lgo/apaache would find /var/log/apache
# shopt -s cdspell
# enable '**'
shopt -s globstar
# enable to execute `cd` command without input `cd`
shopt -s autocd
shopt -s lithist # これを有効にして cmdhist オプションを有効にすると、可能な場合はセミコロン区切り記号を使用するのではなく、改行を埋め込んだ複数行コマンドが履歴に保存される。
shopt -s cmdhist # 複数行のコマンドの全ての行を1つの履歴エントリに保存
# Completion options
#
# These completion tuning parameters change the default behavior of bash_completion:
#
# Define to access remotely checked-out files over passwordless ssh for CVS
# COMP_CVS_REMOTE=1
#
# Define to avoid stripping description in --option=description of './configure --help'
COMP_CONFIGURE_HINTS=1
#
# Define to avoid flattening internal contents of tar files
# COMP_TAR_INTERNAL_PATHS=1
#
# Uncomment to turn on programmable completion enhancements.
# Any completions you add in ~/.bash_completion are sourced last.
[[ -f /etc/bash_completion ]] && . /etc/bash_completion
# Load my config
if [ -f "${HOME}/.bash-env" ]; then
. $HOME/.bash-env
fi
# History Options
#
# Don't put duplicate lines in the history.
export HISTCONTROL=erasedups,ignoreboth,ignorespace
# export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}erasedups,ignorespace
export HISTTIMEFORMAT='%F %T: '
#
# Ignore some controlling instructions
# HISTIGNORE is a colon-delimited list of patterns which should be excluded.
# The '&' is a special pattern which suppresses duplicate entries.
export HISTIGNORE=$'[ \t]*:&:[fb]g:exit:ls:ll:lla:llal:emacs:vim:history:e:v:vs:gs:gv:tig:r:*rm -rf*:r:git push*:*--force*:gm-:git merge:gcmn:gcm:gsp:git stash drop*:..:...:t:l:~:git*--no-verify*:*APP_ENV=production *:git clean -f*'
# shopt -s histverify
if [ "x$BASH_ENV_SHARE_HISTORY" == "x1" ]; then
export PROMPT_COMMAND='share_history'
shopt -u histappend
else
export PROMPT_COMMAND=
shopt -s histappend
fi
share_history() {
history -a
history -c
history -r
}
export HISTSIZE=20000
# Umask
#
# /etc/profile sets 022, removing write perms to group + others.
# Set a more restrictive umask: i.e. no exec perms for others:
# umask 027
# Paranoid: neither group nor others have any perms:
# umask 077
# Functions
#
# Some people use a different file for functions
if [ -f "${HOME}/.bash_functions" ]; then
. "${HOME}/.bash_functions"
fi
#
# Some example functions:
#
# a) function settitle
# settitle ()
# {
# echo -ne "\e]2;$@\a\e]1;$@\a";
# }
#
# Some people use a different file for aliases
if [ -f "${HOME}/.bash_aliases" ]; then
. "${HOME}/.bash_aliases"
fi
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Setting prompt
if [ -f "${HOME}/.dotfiles/gradle-completion.bash" ]; then
. $HOME/.dotfiles/gradle-completion.bash
fi
if [ -f "${HOME}/.config/git/completion/git-prompt.sh" ]; then
. $HOME/.config/git/completion/git-prompt.sh
fi
if [ -f "${HOME}/.config/git/completion/git-completion.bash" ]; then
. $HOME/.config/git/completion/git-completion.bash
fi
if [ -f "${HOME}/.dotfiles/npm-completion.bash" ]; then
. $HOME/.dotfiles/npm-completion.bash
fi
# https://gist.github.com/gibatronic/44073260ffdcbd122e9520756c8e35a1
if [ -f "${HOME}/.dotfiles/npx-completion.bash" ]; then
. $HOME/.dotfiles/npx-completion.bash
fi
GIT_PS1_SHOWUNTRACKEDFILES=1 # %
GIT_PS1_SHOWDIRTYSTATE=1 # * / +
GIT_PS1_SHOWSTASHSTATE=1 # $
GIT_PS1_SHOWUPSTREAM=1 # < / > / = / <>
# https://www.ryotosaito.com/blog/?p=455
#
# PROMPT_COMMAND=__prompt_command
__prompt_command() {
# 最初に直前コマンドの終了ステータスを記録
local status=$?
# SGRパラメータ(文字装飾:色付けを行うためのエスケープシーケンス)
local reset='\001\e[0m\002' red='\001\e[31m\002' green='\001\e[32m\002' yellow='\001\e[33m\002'
# 連想配列で終了ステータスとシグナル名の対応を管理
local -A err_code=(
[1]=ERROR [2]='builtin error' [126]=NO_EXE [127]=TYPO
[128]=SIGHUP [129]=SIGINT [130]=SIGQUIT [131]=SIGILL [132]=SIGTRAP
[133]=SIGABRT [134]=SIGEMT [135]=SIGFPE [136]=SIGKILL [137]=SIGBUS
[138]=SIGSEGV [139]=SIGSYS [140]=SIGPIPE [141]=SIGALRM [142]=SIGTERM
[143]=SIGURG [144]=SIGSTOP [145]=SIGTSTP [146]=SIGCONT [147]=SIGCHLD
[148]=SIGTTIN [149]=SIGTTOU [150]=SIGIO [151]=SIGXCPU [152]=SIGXFSZ
[153]=SIGVTALRM [154]=SIGPROF [155]=SIGWINCH [156]=SIGINFO [157]=SIGUSR1
[158]=SIGUSR2
)
if [[ $status -eq 0 ]]; then
echo -e "$green〇$reset"
elif [[ $status -eq 130 ]]; then
echo -e "$yellow!$status\001\e[2m\002(${err_code[$status]})$reset"
else
echo -e "$redX$status\001\e[2m\002(${err_code[$status]})$reset"
fi
}
uname | grep -q 'NT' > /dev/null 2>&1
if [ $? = 0 ]; then
PS1='\n\[\033[38;5;214m\]\D{%Y/%m/%d %H:%M:%S}\[\033[00m\] \[\033[38;5;220m\]\u@\h\[\033[00m\]'
# Vim
if [[ $VIMRUNTIME != "" ]] ; then
PS1=$PS1' \[\033[5;1;33m\](vim)\[\033[00m\]'
fi
# Ranger
if [[ $RANGER_LEVEL != "" ]] ; then
PS1=$PS1' \[\033[5;38;5;213m\](ranger)\[\033[00m\]'
fi
export PS1=$PS1' \[\033[3;35m\]\w\[\033[00m\]\[\033[31m\]$(__git_ps1)\[\033[00m\]\n\[\033[38;5;213m\]\$\[\033[00m\] '
else
PS1='\n\[\033[38;5;213m\]\D{%Y/%m/%d %H:%M:%S}\[\033[00m\] \[\033[36m\]\u@\h\[\033[00m\]'
# Vim
if [[ $VIMRUNTIME != "" ]] ; then
PS1=$PS1' \[\033[5;1;32m\](vim)\[\033[00m\]'
fi
# Ranger
if [[ $RANGER_LEVEL != "" ]] ; then
PS1=$PS1' \[\033[5;38;5;228m\](ranger)\[\033[00m\]'
fi
export PS1=$PS1' \[\033[3;35m\]\w\[\033[00m\]\[\033[31m\]$(__git_ps1)\[\033[00m\]\n\[\033[33m\]\$\[\033[00m\] '
fi
stty stop undef
stty discard undef
export EDITOR=vim
export MANPAGER="vim +MANPAGER -"
complete -cf sudo
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && . "$HOME/.sdkman/bin/sdkman-init.sh"
PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
PATH="$HOME/.config/alacritty/alacritty.bash:$PATH"
if [[ $(uname) = "Darwin" ]]; then
export PATH="$HOME/.nodebrew/current/bin:$PATH"
fi
PATH="$PATH:$HOME/.config/composer/vendor/bin"
export GOPATH="$HOME/.go"
PATH="$PATH:$HOME/go/bin"
PATH="$GOPATH/bin:$PATH"
export DENO_INSTALL="/home/yosuke/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
if [ "x$BASH_ENV_USE_GOOGLE_IME_SKK" == "x1" ]; then
if ps aux | grep google-ime-skk | grep -vqs grep ; then
: nothing todo
else
google-ime-skk >/dev/null 2>&1 &
fi
else
pkill google-ime-skk
fi
which symfony-autocomplete > /dev/null 2>&1
if [ $? = 0 ]; then
eval "$(symfony-autocomplete)"
fi
which gh > /dev/null 2>&1
if [ $? = 0 ]; then
eval "$(gh completion -s bash)"
fi
if [ -f "${HOME}/.bashrc.local" ]; then
. "${HOME}/.bashrc.local"
fi