Created
September 25, 2024 18:26
-
-
Save natemoo-re/e8f6d1ee6623961da50d22a5e2bb0c90 to your computer and use it in GitHub Desktop.
Copy last SHA
This file contains 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
sha() { | |
value=$(git rev-parse --short HEAD 2>/dev/null) | |
if [ $? -ne 0 ]; then | |
echo "\e[31m▲ Unable to detect latest commit!\e[0m\n\e[2m Is\e[0m \e[36m$(basename "$PWD")\e[0m \e[2ma git repository?\e[0m" >&2 | |
return | |
fi | |
# or `xclip -selection clipboard` on unix | |
echo $value | pbcopy | |
echo "\e[32m●\e[0m Copied \e[36m$value\e[0m to clipboard!" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment