Repository navigation
Expand file tree
/
Copy path.bashrc
More file actions
110 lines (89 loc) · 1.63 KB
/
Copy path.bashrc
File metadata and controls
110 lines (89 loc) · 1.63 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
#### Git functions ####
function gs() {
# git status
git status
}
function ga() {
# git add
git add .
}
function gas() {
# git add status
git add .
git status
}
function grs() {
# git restore --staged
git restore --staged $*
}
function gnb() {
# git checkout -b <new-branch-name>
git checkout -b $*
}
function gcb() {
# git checkout <branch-name>
git checkout $*
}
function gdb() {
# git delete <branch-name>
git branch -d $*
}
function gcm() {
# git commit message "<message>"
git commit -m "$*"
}
function gpo() {
# git push origin <branch-name>
git push origin $*
}
function gpoc() {
# git push origin <current-branch>
local branch=$(git rev-parse --abbrev-ref HEAD)
git push origin "$branch"
}
function grao() {
# git remote add origin <repo-url>
git remote add origin $*
}
#### Navigation functions ####
function @(){
local dir
for depth in {1..3}; do
dir=$(find . -maxdepth $depth -type d -name "*$1*" | head -n 1)
if [[ -n $dir ]]; then
echo "switching to: $dir"
cd "$dir" || return
return
fi
done
echo "no match"
}
function handle_at() {
local base_dir="$1"
shift
if [[ $1 == "@" ]]; then
cd "$base_dir" || return
shift
@ "$@"
else
cd "$base_dir/$*"
fi
}
function c() {
handle_at /c "$@"
}
function tmp() {
handle_at /c/tmp "$@"
}
function release() {
handle_at /c/tmp/release "$@"
}
function tools() {
handle_at /c/tmp/tools "$@"
}
function workspace() {
handle_at /c/tmp/workspace "$@"
}
alias rls='release'
alias tls='tools'
alias ws='workspace'