From fd90802d24c29fcef8715a6c1db77beaa694f084 Mon Sep 17 00:00:00 2001 From: pika Date: Sat, 5 Jul 2025 13:31:29 +0200 Subject: [PATCH] Restructured blesh and made it more robust --- .bashrc | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/.bashrc b/.bashrc index cb7f7d5..72e967f 100644 --- a/.bashrc +++ b/.bashrc @@ -2,14 +2,6 @@ blesh=true -if $blesh; then - [[ $- == *i* ]] && { source /usr/share/blesh/ble.sh --noattach || source "$HOME/.local/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 @@ -45,6 +37,19 @@ echo_info() { _MESSAGES[info]+="${CYAN}ℹ️ $@${NC}\n" } +if $blesh; then + if [ ! -e /usr/share/blesh/ble.sh ] && [ ! -e "$HOME/.local/share/blesh/ble.sh" ]; then + blesh=false + echo_missing blesh + fi +fi + +if $blesh; then + [[ $- == *i* ]] && { source /usr/share/blesh/ble.sh --noattach || source "$HOME/.local/share/blesh/ble.sh" --noattach; } + # Enable history expansion (!!, !$, etc.) in ble.sh + bleopt history_expand_on_space=1 +fi + # Display stored messages error_log() { [[ -z "${_MESSAGES[error]}${_MESSAGES[warn]}${_MESSAGES[info]}${_MESSAGES[missing]}" ]] && return 0 @@ -85,10 +90,10 @@ command_exists() { check_root() { if [ "$(id -u)" -ne 0 ]; then if command_exists sudo; then - echo_warning "User is not root. Using sudo for privileged operations." + # echo_warning "User is not root. Using sudo for privileged operations." _sudo="sudo -E" else - echo_error "No sudo found and you're not root! Can't install packages." + # echo_error "No sudo found and you're not root! Can't install packages." return 1 fi else