From c324fb889dc441831be42cd6dccd3e994e26ebbb Mon Sep 17 00:00:00 2001 From: pika Date: Sun, 8 Jun 2025 11:46:19 +0200 Subject: [PATCH] wip --- .bashrc | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/.bashrc b/.bashrc index 32e638f..cb17b2d 100644 --- a/.bashrc +++ b/.bashrc @@ -1,9 +1,14 @@ #!/usr/bin/env bash -[[ $- == *i* ]] && source /usr/share/blesh/ble.sh --noattach -# Enable history expansion (!!, !$, etc.) in ble.sh -bleopt history_expand_on_space=1 -# Make Tab expand history references (!!, !$, etc.) -ble-bind -f 'TAB' 'complete/expand-history' + +blesh=true + +if $blesh; then + [[ $- == *i* ]] && source /usr/share/blesh/ble.sh --noattach + # Enable history expansion (!!, !$, etc.) in ble.sh + bleopt history_expand_on_space=1 + # Make Tab expand history references (!!, !$, etc.) + ble-bind -f 'TAB' 'complete/expand-history' +fi # ─< Helper functions >───────────────────────────────────────────────────────────────── # ───────────────────────────────────< Message storage >───────────────────────────────── declare -A _MESSAGES @@ -117,6 +122,29 @@ _sources() { done } +setup-keychain() { + setupKeys() { + local keys=( + "homelab-id_rsa" + "hetzner_id_rsa" + ) + + for i in "${keys[@]}"; do + if [ -n $i ]; then + if [ -e "$i" ]; then + eval "$(keychain --eval --noask --agents ssh ~/.ssh/$i)" + fi + else + return 69 + fi + done + } + + if ! setupKeys; then + eval "$(keychain --eval --noask --agents ssh ~/.ssh/{homelab-id_rsa,hetzner_id_rsa})" + fi +} + _init() { # ─< fzf >──────────────────────────────────────────────────────────────────────────────── if command_exists fzf; then @@ -156,6 +184,8 @@ _init() { done fi fi + + setup-keychain } # ─< ble.sh -- https://github.com/akinomyoga/ble.sh >───────────────────────────────────── @@ -213,7 +243,6 @@ _env() { EDITOR=nvim fi - if [[ -z $EDITOR ]]; then if command_exists vim; then EDITOR=vim elif command_exists vi; then @@ -309,4 +338,7 @@ main() { } main -[[ ! ${BLE_VERSION-} ]] || ble-attach + +if $blesh; then + [[ ! ${BLE_VERSION-} ]] || ble-attach +fi