forked from stefanfinseth/git-custom-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-web
More file actions
executable file
·31 lines (23 loc) · 758 Bytes
/
git-web
File metadata and controls
executable file
·31 lines (23 loc) · 758 Bytes
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
#!/bin/zsh
if git status &>/dev/null; then
origin=$(git remote get-url --push origin)
sub_github="github"
sub_gitlab="gitlab"
if [[ "$origin" == *"$sub_github"* ]]; then
git_base="https://github.com"
git_path=${${origin/git@github.com:/}/.git/}
elif [[ "$origin" == *"$sub_gitlab"* ]]; then
git_base="https://gitlab.com"
git_path=${${origin/git@gitlab.com:/}/.git}
else
echo "Unknown git domain..."
exit 1
fi
git_repo_url="${git_base}/${git_path}"
git_branch=$(git branch --show-current)
git_pwd=$(git rev-parse --show-prefix)
git_url="${git_repo_url}/tree/${git_branch}/${git_pwd}"
open "${git_url}"
else
echo "This isn't a git repository..."
fi