Last active
June 14, 2025 22:55
-
-
Save ShoGinn/da37a0e3efa4523c03f3e37623090d0f to your computer and use it in GitHub Desktop.
SOPS KEY File OMZ Plugin
This file contains hidden or 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
# sakf.plugin.zsh | |
# OMZ plugin to quickly set SOPS_AGE_KEY_FILE to an absolute path | |
# Save this file as .oh-my-zsh/custom/plugins/sakf/sakf.plugin.zsh | |
# and add 'sakf' to your plugins list in .zshrc | |
# or run omz plugin add sakf | |
function sakf() { | |
if [ -z "$1" ]; then | |
if [ -n "$SOPS_AGE_KEY_FILE" ]; then | |
echo "SOPS_AGE_KEY_FILE is set to: $SOPS_AGE_KEY_FILE" | |
else | |
echo "SOPS_AGE_KEY_FILE is not set.\nUsage: sakf <path_to_key_file>" | |
fi | |
return 0 | |
fi | |
local keyfile="$(realpath "$1")" | |
if [ ! -r "$keyfile" ]; then | |
echo "Error: File '$keyfile' does not exist or is not readable." | |
return 1 | |
fi | |
if ! grep -q 'AGE-SECRET-KEY-' "$keyfile"; then | |
echo "Error: File '$keyfile' does not appear to be a valid Age key file." | |
return 1 | |
fi | |
export SOPS_AGE_KEY_FILE="$keyfile" | |
echo "SOPS_AGE_KEY_FILE set to $SOPS_AGE_KEY_FILE" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment