nix/scripts/bin/open-in-git-forge
2023-09-05 15:15:43 -05:00

21 lines
483 B
Bash
Executable file

#!/usr/bin/env sh
usage() {
echo "open-in-git-forge <$FILE>[#L$LINE_NUMBERS]"
echo " Opens the URL in your browser to the git forge's web interface for the current branch for $FILE"
echo
echo " Examples:"
echo " \$ open-in-git-forge readme.md#L12"
}
if [ "$#" -lt 1 ]; then
usage
exit 1
fi
url="$(gitforge-url.ts "$1")"
case "$(uname)" in
Linux*) xdg-open "$url";;
Darwin*) open "$url";;
*) echo "OS not supported"; exit 1;
esac