Created
May 4, 2018 13:33
-
-
Save taikedz/1ec81daed066433dbfce94aa2162437f to your computer and use it in GitHub Desktop.
View a java keystore contents with some colorization for easier reading.
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
#!/bin/bash | |
main() { | |
if [[ -z "$*" ]] || [[ "$*" =~ --help ]]; then | |
echo "Provide the path to a keystore to colorize its output" | |
else | |
keystore="$1" | |
dump_keystore | colorize_keystore_stream | c_less | |
fi | |
} | |
cred="$(echo -e "\033[31;1m")" | |
cgrn="$(echo -e "\033[32;1m")" | |
cyel="$(echo -e "\033[33;1m")" | |
cdef="$(echo -e "\033[0m")" | |
c_less() { | |
/bin/less -R | |
} | |
dump_keystore() { | |
keytool -list -v -keystore "$keystore" | |
} | |
colorize_keystore_stream() { | |
# The order of the steps is important | |
sed -r " | |
s/^Alias name:/${cred}Alias name:${cdef}/ | |
s/^([a-zA-Z0-9 -]+:)/${cgrn}\1${cdef}/ | |
s/^(#[0-9]:)/${cyel}\1${cdef}/ | |
" | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment