all repos — dot @ master

Shell, editor and terminal configuration, and the tools that go with them

secrets/list.sh (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
#!/bin/bash

set -euo pipefail

if [[ "$#" -gt 0 && ("$1" == "-h" || "$1" == "--help") ]]; then
    cat <<EOF
list: List all available secrets in the store

Displays all secret names in the global store in a columnar format.

Usage:
  list
  list -h|--help

The command will:
1. List all .age files in the store directory
2. Remove the .age extension from filenames
3. Display the secret names in columns

Note: Only shows secret names, not their values.
EOF
    exit 0
fi

this_dir="$(cd "$(dirname "$(realpath "$0")")" && pwd)"
source "${this_dir}/common.sh"

maybe_column() {
    if [ -t 1 ]; then
        column
    else
        cat
    fi
}

ls "${store}" | sed 's/\.age$//' | sort | maybe_column