-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
98 lines (83 loc) · 2.31 KB
/
.zshrc
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
# Assuming that you are working a go project and you want to check the project before committing the changes
alias check-project='{
# Check if the current directory is in the project directory
if [ ! -d "/Users/user/Documents/github.com/project" ]; then
echo "You are not in the project directory!";
return 1;
fi;
# Check unit test
go test ./...;
if [ $? -ne 0 ]; then
echo "Test failed!";
return 1;
fi;
# Check lint
golangci-lint run --fix;
if [ $? -ne 0 ]; then
echo "Lint failed!";
return 1;
fi;
# Ready to commit
echo "All good, ready to commit!";
}'
# Commit reminder
alias gitcommit='{
# Prompt to test the changes manually
read -q "REPLY? Do you done tested it manually? [y/N]: ";
echo;
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Remember to test it manually!";
return 1;
fi;
# Prompt to test the changes using unit test
read -q "REPLY? Do you done tested it using unit test? [y/N]: ";
echo;
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Remember to test it using unit test!";
return 1;
fi;
# Prompt to proceed with the commit
read -q "REPLY? Do you want to proceed with the commit? [y/N]: ";
echo;
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Commit aborted!";
return 1;
fi;
# If all the prompts are passed, then proceed with the commit
git commit;
}'
# Push reminder
alias gitpush='{
# Prompt to test the changes manually
read -q "REPLY? Do you done tested it manually? [y/N]: ";
echo;
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Remember to test it manually!";
return 1;
fi;
# Prompt to test the changes using unit test
read -q "REPLY? Do you done tested it using unit test? [y/N]: ";
echo;
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Remember to test it using unit test!";
return 1;
fi;
# Prompt to proceed with the push
read -q "REPLY? Do you want to proceed with the push? [y/N]: ";
echo;
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Push aborted!";
return 1;
fi;
# If all the prompts are passed, then proceed with the push
git push;
}'
# cherry-pick alias, an alias with a parameter
alias cherry-picker='f() {
if [ -z "$1" ]; then
echo "Please provide the commit hash!";
return 1;
fi;
git cherry-pick -m 1 $1;
echo "Cherry-picking commit $1";
};f'