This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/common/bin/copy-git-forge-url

21 lines
486 B
Plaintext
Raw Permalink Normal View History

2023-04-13 14:04:29 -05:00
#!/usr/bin/env sh
2023-07-17 11:23:37 -05:00
usage() {
echo "copy-git-forge-url <$FILE>[#L$LINE_NUMBERS]"
echo " Copies a link to the git forge's web interface for the current branch to the clipboard"
echo
echo " Examples:"
echo " \$ copy-git-forge-url readme.md#L12"
}
if [ "$#" -lt 1 ]; then
usage
exit 1
fi
2023-04-13 14:04:29 -05:00
url="$(gitforge-url.ts "$1")"
case "$(uname)" in
Linux*) echo "$url" | clip;;
2023-07-17 11:23:37 -05:00
Darwin*) echo "$url" | clip;;
2023-04-13 14:04:29 -05:00
*) echo "OS not supported"; exit 1;
esac