Restructured blesh and made it more robust
This commit is contained in:
parent
3389fe8cc7
commit
fd90802d24
1 changed files with 15 additions and 10 deletions
25
.bashrc
25
.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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue