Skip to content

Instantly share code, notes, and snippets.

@AlbinoDrought
Created August 19, 2025 21:28
Show Gist options
  • Save AlbinoDrought/a8152f4667b354527ab5c2f609edc72b to your computer and use it in GitHub Desktop.
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"
#!/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