-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash.aliases
More file actions
169 lines (135 loc) · 4.84 KB
/
bash.aliases
File metadata and controls
169 lines (135 loc) · 4.84 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
#!/bin/bash
hypdir="/D/hanyi/project/"
studydir="/D/study/"
cemdir="${hypdir}cem-demo"
vfocusdir="${hypdir}vue-focus"
libdir="${studydir}library/"
iwdir="${studydir}preperation4interview/"
sdir="${studydir}study/"
hdadmin="/D/hd/cdt-admin/"
hdh5="/D/hd/cdt-h5"
# 推送到远程分支
# @param $1 远程分支名称,必须, $2为分支tagname,非必须
function mto() {
# 参数校验 $#: 表示所有参数个数,但最后一个参数不能用${$#},因为是特殊字符,应该用${!#}
# $*,$@表示所有参数, $*把所有参数作为一个整体,而$@每个参数都是一个个体可以用for遍历
# $?来保存上个已执行命令的退出状态码, 成功退出状态码为0, 有错退出状态码为正值
# $0当前 shell 名称(zsh or bash)或脚本的名字
# $_ 代表上一个命令的最后一个参数
# $$ 脚本运行的当前进程ID号或所在命令的PID。
# $! 代表最后执行的后台命令的PID
#[ $# -ne 1 ] && {
# echo 'usage: pushbr [branch-name]'
# return 1
#}
#
# if [ ! -n "$1" ]
# 第一个参数长度为零或者第一个参数是--help则提示帮助信息
if [ -z "$1" ] || [ "$1" = "--help" ]
then
echo 'usage: mto target-branch-name [tagname]';
printf "%-19s%-10s%-8s\n" "target-branch-name:" "" "tagname:";
printf "%-19s%-8s%-10s%-8s\n" "" "必选参数" "" "可选参数";
return 1
fi
# 先保证本地feature版本是最新的
git pull --no-edit &&\
git checkout $1 &&\
git pull --no-edit &&\
git merge - --no-edit &&\
git push &&\
# 需要打tag $2:tagname
if [ -n "$2" ]
then
echo "$1 branch will tag, tagname is $2"
git tag $2 &&\
git push origin $2
fi
git checkout -;
}
function gtag(){
if [ -z "$1" ]
then
echo 'usage: gtag tagname';
return 1
fi
git checkout master &&\
git pull --no-edit &&\
git tag $1 &&\
git push origin $1
}
# r2 branchname,当前分支代码rebase到目标分支branchname上
r2() {
if [ $# -eq 0 ]; then
echo "Usage: r2 <branchname>"
echo "Rebases current branch into the specified branch"
return 1
fi
local target_branch="$1"
local current_branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$current_branch" = "$target_branch" ]; then
echo "Cannot rebase a branch into itself"
return 1
fi
echo "Rebasing $current_branch into $target_branch..."
git pull --rebase &&\
git checkout "$target_branch" &&\
git pull --rebase &&\
git rebase "$current_branch" &&\
if [ $? -ne 0 ]; then
echo "Rebase encountered conflicts. Resolve them and run 'git rebase --continue'"
return 1
fi
git checkout "$current_branch" &&\
echo "Successfully rebased $current_branch into $target_branch"
}
#alias mto='_mto'
# notepad++ open file, 需要对空格转义
#alias np="/D/Program\ Files/Notepad++/notepad++.exe"
function np(){
/D/Program\ Files/Notepad++/notepad++.exe $1 &
}
# vscode open file
alias vscode="/C/Users/EDZ/AppData/Local/Programs/Microsoft\ VS\ Code/Code.exe &"
# chrome
alias chrome="/C/Program\ Files/Google/Chrome/Application/chrome.exe &"
alias debugchrome="/C/Program\ Files/Google/Chrome/Application/chrome.exe -remote-debugging-port=9871 &"
alias chromeold="/D/soft/Win_x64_782797_chrome-win/chrome-win/chrome.exe &"
# 后台运行clash nohup: no hang up不挂起运行 /dev/null 2>&1 标准错误输入标准输入到/dev/null(空文件,即忽略错误) &后台运行
function clash() {
#nohup /D/soft/Clash.for.Windows-0.16.2-win/Clash\ for\ Windows.exe > /dev/null 2>&1 &
nohup /D/Program\ Files\ \(x86\)/clash/Clash\ for\ Windows.exe > /dev/null 2>&1 &
};
function xmly(){
nohup /D/Program\ Files\ \(x86\)/ximalaya-pc/喜马拉雅.exe > /dev/null 2>&1 &
};
#_xmly(){
# nohup /D/Program\ Files\ \(x86\)/ximalaya-pc/喜马拉雅.exe > /dev/null 2>&1 &
#};
#alias xmly='_xmly'
alias wechat="/C/Users/EDZ/Desktop/wechat-bat2.bat &"
alias qq="/D/Program\ Files\ \(x86\)/Tencent/QQ/Bin/QQ.exe &"
alias zeal="/D/Program\ Files/zeal-portable-0.6.1-windows-x64/zeal.exe &"
alias baidu="/D/Program\ Files\ \(x86\)/BaiduNetdisk/baidunetdisk.exe &"
alias music="/D/Program\ Files\ \(x86\)/Netease/CloudMusic/cloudmusic.exe &"
#alias dy="/D/Program\ Files\ \(x86\)/ByteDance/douyin/douyin.exe &"
function dy(){
nohup /D/Program\ Files\ \(x86\)/ByteDance/douyin/douyin.exe > /dev/null 2>&1 &
}
#alias dy2="/C/ProgramData/Microsoft/Windows/Start\ Menu/Programs/抖音/抖音 &"
alias xshell="/D/Program\ Files\ \(x86\)/NetSarang/Xshell\ 7/Xshell.exe"
alias hosts="np /C/Windows/System32/drivers/etc/hosts"
# git alias
alias ga='git add'
alias gaa='git add --all'
alias gb='git branch'
alias gba='git branch -a'
alias gbd='git branch -d'
alias gcm='git commit -m'
alias gp='git push'
alias gl='git pull'
# checkout
alias gco='git checkout'
alias gcb='git checkout -b'
# merge
alias gm='git merge'