#!/bin/sh set -e rage_dir=~/.rage rage_id_file="$(awk -F= '/^identity/{print $NF}' ${rage_dir}/config)" rage_id_recip="$(awk -F= '/^identity/{print $NF ".pub"}' ${rage_dir}/config)" cmd=$1 list() { find $rage_dir -type f -name \*.age } if [ -z ${cmd} ]; then list exit fi case $cmd in ls) list ;; en) printf 'Password: ' stty -echo read pass stty echo echo "" printf 'Location: ' read loc echo "" mkdir -p "$(dirname ~/.rage/${loc})" echo "$pass" | age -r "$(cat ${rage_id_file}.pub)" > ~/.rage/${loc}.age ;; de) age -i $rage_id_file -d $2 ;; default) list esac