diff --git a/.zshrc b/.zshrc index 20a62ed..d06dfc2 100644 --- a/.zshrc +++ b/.zshrc @@ -285,8 +285,6 @@ export PYENV_ROOT="$HOME/.pyenv" [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" -. "$HOME/.cargo/env" - zstyle ':completion:*' menu select fpath+=~/.zfunc @@ -309,16 +307,39 @@ function load_nvm() { export IDENTITY="Christoph J. Scherr " export KEY_TYPE=ed25519 export KEYID=0E777B31ACC5B69B7096C050A466E5C5D6792EE9 -gpgencrypt () { - output="${1}".$(date +%s).enc - gpg --encrypt --armor --output ${output} \ - -r $KEYID "${1}" && echo "${1} -> ${output}" +gpgencrypt() { + # Encrypt with progress indicator + gpg --encrypt --armor \ + --sign \ + -r "${KEYID}" $@ } -gpgdecrypt () { - output=$(echo "${1}" | rev | cut -c16- | rev) - gpg --decrypt --output ${output} "${1}" && \ - echo "${1} -> ${output}" +gpgsign() { + local input="${1:--}" # Default to stdin if no argument + if [[ "${input}" != "-" ]] && [[ ! -f "${input}" ]]; then + echo "Error: Input file '${input}' not found" + return 1 + fi + gpg --clearsign --default-key "${KEYID}" "${input}" +} + +gpgverify() { + local input="${1:--}" # Default to stdin if no argument + if [[ "${input}" != "-" ]] && [[ ! -f "${input}" ]]; then + echo "Error: Input file '${input}' not found" + return 1 + fi + gpg --verify "${input}" +} + +# Git signing convenience function +gcsign() { + git commit --amend --gpg-sign="${KEYID}" --allow-empty --signoff +} + +gpgexport() { + # Export public key + gpg --armor --export "${KEYID}" > "${1:-public_key.asc}" } ### load unversioned zsh code