-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_bashrc
196 lines (165 loc) · 5.5 KB
/
dot_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
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do enything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
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
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
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'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# pathの追加
PATH=$PATH:$HOME/usr/local/bin
PATH=$PATH:/usr/local/sbin
PATH=$PATH:/usr/local/bin
PATH=$PATH:/usr/sbin
PATH=$PATH:/usr/bin
PATH=$PATH:/sbin
PATH=$PATH:/bin
PATH=$PATH:/usr/games
PATH=$PATH:/usr/local/games
PATH=$PATH:/usr/local/go/bin
PATH=$PATH:/snap/bin
PATH=$PATH:$HOME/bin
PATH=$PATH:$HOME/.cargo/bin
PATH=$PATH:$HOME/.local/bin
PATH=$PATH:$HOME/.istioctl/bin
PATH=$PATH:$HOME/go/bin
PATH=$PATH:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/
PATH=$PATH:${KREW_ROOT:-$HOME/.krew}/bin
PATH=$PATH:${AQUA_ROOT_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/aquaproj-aqua}/bin
export PATH
export AQUA_GLOBAL_CONFIG=$HOME/aqua.yaml
# vim風
set editiong-mode vi
set show-mode-in-prompt on
set vi-ins-mode-string "+"
set vi-cmd-mode-string ":"
#screen用 PS1の設定
set_prompt_command () {
screen_hstatus="${PWD} [${USER}@${HOSTNAME}]"
screen_hstatus_str="\033]0;$screen_hstatus\007"
echo -ne "$screen_hstatus_str"
}
if [ $(echo "$TERM" | grep -e 'xterm' -e 'screen' ) ]; then
export PS1='\$ '
export PROMPT_COMMAND="set_prompt_command"
else
export PS1='\u@\h:\W\$ '
fi
function peco-select-history() {
declare l=$(HISTTIMEFORMAT= history | sort -k1,1nr | perl -ne 'BEGIN { my @lines = (); } s/^\s*\d+\s*//; $in=$_; if (!(grep {$in eq $_} @lines)) { push(@lines, $in); print $in; }' | peco --query "$READLINE_LINE")
READLINE_LINE="$l"
READLINE_POINT=${#l}
}
function ghql() {
local selected_file=$(ghq list --full-path | peco --query "$LBUFFER")
if [ -n "$selected_file" ]; then
if [ -t 1 ]; then
echo ${selected_file}
cd ${selected_file}
fi
fi
}
bind -x '"\C-r": peco-select-history'
bind -x '"\C-]": ghql'
gcop() {
git branch -v -a --sort=-authordate |
grep -v -e '->' -e '*' |
peco |
sed -r 's#^\s*(remotes/origin/)?([^ ]+)\s*.+#\2#g' |
xargs git checkout
}
bind -x '"\C-b": gcop'
alias tmux="tmux new-session -A -s local"
export EDITOR="vim"
[ -f "${HOME}/.config/git-prompt.sh" ] && source "${HOME}/.config/git-prompt.sh"
_git_completion() {
unset -f _git_completion
complete -r git
[ -f "${HOME}/.config/git-completion.bash" ] && source "${HOME}/.config/git-completion.bash" && return 124
}
complete -F _git_completion git
## aws-vault
export AWS_VAULT_BACKEND="pass"
# original from: https://github.com/j-szulc/evalcache/blob/02bc6de8fb9d2c707e9c3af57e674dd8a1a94cf0/evalcache.sh
evalcache () {
cache_file="$HOME/.cache/$(cksum <<< "$*")"
cache_file="${cache_file%% *}"
if [ -f "$cache_file" ]
then
cat "$cache_file"
(
"$@" > "$cache_file" &
)
else
"$@" > "$cache_file"
cat "$cache_file"
fi
}
eval "$(evalcache direnv hook bash)"
KUBECONFIG="$HOME/.kube/config"
[ -e "$HOME/.kube/k3s.yaml" ] && KUBECONFIG="$KUBECONFIG:$HOME/.kube/k3s.yaml"
alias k3ctl="sudo k3s kubectl"
export KUBECONFIG
gcloud() {
unset -f gcloud
gcloud_path=$(aqua which gcloud)
[ -f "${gcloud_path%/bin/gcloud}/path.bash.inc" ] && source "${gcloud_path%/bin/gcloud}/path.bash.inc"
gcloud "$@"
}
_gcloud_completion() {
unset -f _gcloud_completion
gcloud_path=$(aqua which gcloud)
complete -r gcloud
[ -f "${gcloud_path%/bin/gcloud}/completion.bash.inc" ] && source "${gcloud_path%/bin/gcloud}/completion.bash.inc" && return 124
}
complete -F _gcloud_completion gcloud
gcloud-switch() {
local selected=$(
gcloud config configurations list --format='table[no-heading](is_active.yesno(yes="[x]",no="[_]"), name, properties.core.account, properties.core.project.yesno(no="(unset)"))' \
| fzf --select-1 --query="$1" \
| awk '{print $2}'
)
if [ -n "$selected" ]; then
rm $HOME/.kube/gke_gcloud_auth_plugin_cache
gcloud config configurations activate $selected
fi
}
bind -x '"\C-g": gcloud-switch'