Last active
February 25, 2024 15:40
-
-
Save tippfehlr/843c2d11f356d37495670b5803b714f5 to your computer and use it in GitHub Desktop.
Think of a port ðŸ’
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
# bash function to generate ports for projects | |
# use the first four non-zero digits from the sha256sum of the project’s name | |
# infer the name from the current directory if no argument is given | |
thinkofport() { | |
if [ "$#" -gt 0 ]; then | |
echo -n "$1" | sha256sum | grep -o '[1-9]' | head -n 4 | tr -d '\n' | |
else | |
basename "$(pwd)" | sha256sum | grep -o '[1-9]' | head -n 4 | tr -d '\n' | |
fi | |
} |
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
# fish function to generate ports for projects | |
# use the first four non-zero digits from the sha256sum of the project’s name | |
# infer the name from the current directory if no argument is given | |
function thinkofport | |
if count $argv >/dev/null | |
echo $argv | sha256sum | grep -o '[1-9]' | head -n 4 | tr -d '\n' | |
else | |
basename (pwd) | sha256sum | grep -o '[1-9]' | head -n 4 | tr -d '\n' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment