Created
August 19, 2025 21:28
-
-
Save AlbinoDrought/a8152f4667b354527ab5c2f609edc72b to your computer and use it in GitHub Desktop.
Script to open current repo on Gitlab.com. Save as "git-lab" and run as "git lab"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get the remote URL and extract the GitLab project path | |
remote_url=$(git remote get-url origin) | |
# Convert SSH URL to HTTPS URL | |
if [[ $remote_url == [email protected]:* ]]; then | |
# Extract the path after '[email protected]:' | |
project_path=${remote_url#[email protected]:} | |
# Remove .git suffix if present | |
project_path=${project_path%.git} | |
# Build HTTPS URL | |
gitlab_url="https://gitlab.com/$project_path" | |
elif [[ $remote_url == https://gitlab.com/* ]]; then | |
# Already HTTPS, just remove .git suffix if present | |
gitlab_url=${remote_url%.git} | |
else | |
echo "Error: Remote URL format not supported: $remote_url" | |
exit 1 | |
fi | |
# Open the URL | |
echo "Opening: $gitlab_url" | |
xdg-open "$gitlab_url" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment