| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | brt_publickey() { |
| 4 | local keyfile="${1:-${HOME}/.ssh/id_ed25519.pub}" |
| 5 | keyfile="${keyfile%.pub}.pub" |
| 6 | [[ -f "$keyfile" ]] || keyfile="${1:-${HOME}/.ssh/id_rsa.pub}" |
| 7 | |
| 8 | if [[ ! -f "$keyfile" ]]; then |
| 9 | brt_error "Public key not found: ${keyfile}" |
| 10 | brt_info "Usage: brt -publickey [path/to/key.pub]" |
| 11 | exit 1 |
| 12 | fi |
| 13 | |
| 14 | brt_info "Public key (${keyfile}):" |
| 15 | cat "$keyfile" |
| 16 | |
| 17 | if command -v pbcopy &>/dev/null; then |
| 18 | pbcopy < "$keyfile" |
| 19 | brt_ok "Copied to clipboard" |
| 20 | fi |
| 21 | } |
| 22 | |