From e85e4bb65d437c557e61b578af15356d0265429b Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Sun, 15 Feb 2026 03:40:40 +0000 Subject: [PATCH] Add blerc. (#6) --- .bash_aliases | 7 +++++- .blerc | 54 +++++++++++++++++++++++++++++++++++++++++++++++ .config/yakuakerc | 2 +- .gitignore | 1 + setup.sh | 31 +++++++++++++++++++++++++-- 5 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 .blerc diff --git a/.bash_aliases b/.bash_aliases index dbaae94..4fbf4f7 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -1,3 +1,8 @@ +# Source ble.sh if installed. +if [ -f ~/.local/share/blesh/ble.sh ]; then + source -- ~/.local/share/blesh/ble.sh +fi + # Source rust things if they exist if [ -f ~/.cargo/env ]; then . ~/.cargo/env @@ -11,7 +16,7 @@ if [ -f /.dockerenv ]; then alias ,init='apt update -y && apt install -y $DOT_PACKAGES' alias ,swap='swapoff -a && swapon -a' else - export DOT_PACKAGES='git stow vim vim-gtk3 xsel xclip tmux ranger clang yakuake wget curl golang-go' + export DOT_PACKAGES='git stow vim vim-gtk3 xsel xclip tmux ranger clang yakuake wget curl golang-go gawk' alias ,update='sudo apt update -y && sudo apt upgrade -y && sudo apt upgrade --fix-broken --fix-missing --auto-remove' alias ,init='sudo apt update -y && sudo apt install -y $DOT_PACKAGES' # Clear kscreen cached settings diff --git a/.blerc b/.blerc new file mode 100644 index 0000000..01a27d6 --- /dev/null +++ b/.blerc @@ -0,0 +1,54 @@ +# Insert date-time string within a bash prompt using `\dt` +function blerc/define-sabbrev-dt { + ble-sabbrev -m '\dt'='ble/util/assign COMPREPLY "date +%F_%H-%M-%S"' +} +blehook/eval-after-load complete blerc/define-sabbrev-dt + +# Insert the time within a bash prompt using `\time` +function blerc/define-sabbrev-time { + ble-sabbrev -m '\time'='ble/util/assign COMPREPLY "date +%H-%M-%S"' +} +blehook/eval-after-load complete blerc/define-sabbrev-time + +# Insert the date within a bash prompt using `\date` +# https://github.com/akinomyoga/ble.sh/wiki/Recipes#r1-insert-date-through-sabbrev-date +function blerc/define-sabbrev-date { + ble-sabbrev -m '\date'='ble/util/assign COMPREPLY "date +%F"' +} +blehook/eval-after-load complete blerc/define-sabbrev-date + +# Interactive git branch selection with `\branch` +# https://github.com/akinomyoga/ble.sh/wiki/Recipes#r2-insert-git-branch-name-from-menu-through-sabbrev-branch +function blerc/define-sabbrev-branch { + function blerc/sabbrev-git-branch { + ble/util/assign-array COMPREPLY "git branch | sed 's/^\*\{0,1\}[[:blank:]]*//'" 2>/dev/null + } + ble-sabbrev -m '\branch'=blerc/sabbrev-git-branch +} +blehook/eval-after-load complete blerc/define-sabbrev-branch + +# Interactive git commit selection with `\commit` +# https://github.com/akinomyoga/ble.sh/wiki/Recipes#r3-insert-git-commit-id-from-menu-through-sabbrev-commit +function blerc/define-sabbrev-commit { + ble/color/defface blerc_git_commit_id fg=63 + ble/complete/action#inherit-from blerc_git_commit_id word + function ble/complete/action:blerc_git_commit_id/init-menu-item { + local ret + ble/color/face2g blerc_git_commit_id; g=$ret + } + function blerc/sabbrev-git-commit { + bleopt sabbrev_menu_style=desc-raw + bleopt sabbrev_menu_opts=enter_menu + + local format=$'%h \e[1;32m(%ar)\e[m %s - \e[4m%an\e[m\e[1;33m%d\e[m' + local arr; ble/util/assign-array arr 'git log --pretty=format:"$format"' &>/dev/null + local line hash subject + for line in "${arr[@]}"; do + builtin read hash subject <<< "$line" + ble/complete/cand/yield blerc_git_commit_id "$hash" "$subject" + done + } + ble-sabbrev -m '\commit'='blerc/sabbrev-git-commit' +} +blehook/eval-after-load complete blerc/define-sabbrev-commit + diff --git a/.config/yakuakerc b/.config/yakuakerc index 12b814d..ad97a91 100644 --- a/.config/yakuakerc +++ b/.config/yakuakerc @@ -49,4 +49,4 @@ ShowOnAllDesktops=true ShowSystrayIcon=true ShowTabBar=true ShowTitleBar=true -ToggleToFocus=false \ No newline at end of file +ToggleToFocus=false diff --git a/.gitignore b/.gitignore index d9cea87..119fc93 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ .config/Code/rapid_render.json .config/Code/Network* **/.config/.brightness +.local/share/fonts/.uuid # Byte-compiled / optimized / DLL files *__pycache__/ diff --git a/setup.sh b/setup.sh index 9d7f067..1d8e11e 100755 --- a/setup.sh +++ b/setup.sh @@ -1,6 +1,33 @@ #!/usr/bin/env bash -git submodule update --init +set -Eeuo pipefail + +# $1: Error message +# $2: Error code +function fatal() { + local msg=${1:-"Unspecified error"} + echo "[Error:$LINENO] Could not install dotfiles: $msg" + exit ${2:-1} +} +trap 'fatal "Trapped an unknown error" $?' ERR + +if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + fatal "Run setup.sh from the root directory of the dotfiles repository." 2 +fi +git submodule update --init --recursive + # Use alias for installing packages so we don't maintain several dependency lists. +if ! [[ -f .bash_aliases ]]; then + fatal "Failed to locate .bash_aliases in path: $(pwd)" 3 +fi . .bash_aliases -,init + +if [[ -z ${DOT_PACKAGES:-} ]]; then + fatal "DOT_PACKAGES variable not found after sourcing $(pwd)/.bash_aliases" 4 +fi +sudo apt update -y && sudo apt install -y $DOT_PACKAGES go install github.com/arl/gitmux@latest + +# Install bash line editor for auto completion. +git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git +make -C ble.sh install PREFIX=$(pwd)/.local +rm -rf ble.sh