-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
97 lines (78 loc) · 1.8 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
COLOR_USER_HOST="\[\e[32m\]"
COLOR_DIR="\[\e[33m\]"
COLOR_RESET="\[\e[0m\]"
# $1 に設定したやつを追加で表示
set_ps1() {
if [ -z $1 ];
then
PS1="${COLOR_USER_HOST}\u@\h:${COLOR_DIR}\W \t > ${COLOR_RESET}"
else
PS1="${COLOR_USER_HOST}\u@\h:${COLOR_DIR}\W \t [$1] > ${COLOR_RESET}"
fi
}
set_ps1
# セッションクローズ時の.bash_historyへの書き込みをoff
shopt -u histappend
# .bash_historyとメモリ上のコピーを頻繁に同期
share_history(){
history -a
history -c
history -r
}
# PROMPT_COMMAND
prompt_dispatch() {
current=$(git branch 2>/dev/null | grep '*' | cut -f2 -d' ')
set_ps1 $current
share_history
}
PROMPT_COMMAND='prompt_dispatch'
# bind
if [ -t 1 ];then
bind -x '"\C-k\C-k" : ll'
bind -x '"\C-k\C-p" : pwd'
bind -x '"\C-g\C-b" : echo "git branch";git branch'
bind -x '"\C-g\C-d" : echo "git diff";git diff'
bind '"\C-f": forward-word'
bind '"\C-b": backward-word'
fi
if [[ -t 0 ]]; then
stty stop undef
stty start undef
fi
# alias
source ~/.bash_aliases
# function
function vimemo() {
vi ~/memos/memo_`date +%Y_%m_%d`
}
function lastdir() {
dir=$(cat ~/.lastdir)
echo $dir
cd $dir
}
function removeLastLine() {
ruby -i -e 'print ARGF.read.strip' $1
}
function gco_select() {
select branch in $(git branch | sed -e "s/* /[current]/")
do
git checkout "$branch"
break
done
}
function rm_select() {
echo 'select delete file'
echo 'specify multiple files separated by commas'
eval dirList=("$(ls --quoting-style=shell)")
for ((i = 0; i < ${#dirList[@]}; i++))
do
echo "$i => ${dirList[$i]}"
done
read -p "input num > " ans
for num in $(echo $ans | tr ',' '\n')
do
rm -i "${dirList[$num]}"
done
}
export NODE_OPTIONS="--max-old-space-size=8192"
eval "$(nodenv init -)"