forked from Mopip77/dotfile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyScript
127 lines (114 loc) · 3.14 KB
/
myScript
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
#!/bin/bash
# alias
alias mv="mv -i" # overwrite prompt
alias cp="cp -i" # overwrite prompt
alias tnew="tmux new -s"
alias o="open"
alias nvi="nvim"
alias gdhh="git diff HEAD HEAD^"
alias gs="git status -s"
alias gl="lazygit"
alias rr="ranger"
alias k="kubectl"
alias T="([ ! -e /tmp/T ] && mkdir /tmp/T); cd /tmp/T"
alias agf="ag -l -g"
alias tt="fzf --preview 'bat --style=numbers --color=always --line-range :500 {}'"
alias localFirst="PATH=${HOME}/.local/bin:$PATH"
alias proxy="export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7891"
alias reset-proxy="export https_proxy= http_proxy= all_proxy="
alias noti="osascript -e 'display notification \"\" with title \"Mission finished!\"'"
# path
export JAVA_HOME="/Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home"
export PATH=${PATH}:${JAVA_HOME}/bin
export GRADLE_USER_HOME="${HOME}/.m2/repository/"
export PATH=${PATH}:${HOME}/go/bin
export PATH=${PATH}:${HOME}/.local/bin
export PATH=${PATH}:${HOME}/grampro/jmeter/bin
# global config
# brew 禁止自动更新
export HOMEBREW_NO_AUTO_UPDATE=1
switch_java() {
if [ $# = 0 ]; then
echo "switch_java <version> version: 8, 11, 14"
else
case "$1" in
"8")
export JAVA_HOME="/Library/Java/JavaVirtualMachines/zulu_jdk8_arm/zulu-8.jdk/Contents/Home"
export PATH=${PATH}:${JAVA_HOME}/bin
;;
"11")
export JAVA_HOME="/Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home/"
export PATH=${PATH}:${JAVA_HOME}/bin
;;
"14")
export JAVA_HOME="/Library/Java/JavaVirtualMachines/openjdk-14.0.1.jdk/Contents/Home/"
export PATH=${PATH}:${JAVA_HOME}/bin
;;
esac
fi
}
goto() {
cd "$(dirname $1)"
}
note() {
NOTE_PATH="${HOME}/Documents/note"
[[ ! -d $PATH ]] && mkdir -p $NOTE_PATH
dt=$(date +"%Y-%m-%d_%H:%M:%S")
fileName="$dt.md"
if [ "$1" = "-a" ]; then
recentFile=$(ls -t $NOTE_PATH | head -n1)
[[ ! -z $recentFile ]] && fileName=$recentFile
fi
nvim $NOTE_PATH/$fileName
}
qr() {
tmp_qr_path="tmp.png"
if [ $# -eq 1 ]
then
text=$1
else
# 默认使用剪贴板
text=`xclip -o`
fi
qrencode $text -o $tmp_qr_path -s 7
xviewer $tmp_qr_path
rm $tmp_qr_path
}
# photoscaner
# 为了快捷,默认读取pictures文件夹下的最新的图片
# 只接收 o(ocr) b(base64) u(upload)
pho() {
screenshotPath="${HOME}/Pictures/screenshot/"
curPath=$( pwd )
if [ $# -eq 2 ]
then
if [ "${2:0:1}" = "/" ]
then
# 绝对路径
pic_file="$2"
else
# 默认当前路径,有../类似的相对路径就不处理了
pic_file="$curPath/$2"
fi
if [ $1 = 'cp' ];then
pic_file=$(ls -t $screenshotPath | head -1)
pic_file="$screenshotPath$pic_file"
cp "${pic_file}" "$2"
return 0
fi
elif [ $# -eq 1 ]
then
pic_file=$(ls -t $screenshotPath | head -1)
pic_file="$screenshotPath$pic_file"
fi
python3 ${HOME}/.myjiaoben/pho/photoscaner.py $1 ${pic_file}
cd $curPath
}
gnb() {
if [ -z "`git br | grep -E "\btest/authority\b"`" ]
then
git checkout -b ${1} && git push -u origin ${1}:${1}
else
git checkout ${1} && git push -u origin ${1}:${1}
fi
}