Add blerc. (#6)

This commit was merged in pull request #6.
This commit is contained in:
2026-02-15 03:40:40 +00:00
parent 6b6e88dcbb
commit e85e4bb65d
5 changed files with 91 additions and 4 deletions

View File

@@ -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

54
.blerc Normal file
View File

@@ -0,0 +1,54 @@
# Insert date-time string within a bash prompt using `\dt<SP>`
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<SP>`
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<SP>`
# 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<SP>`
# 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<SP>`
# 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

View File

@@ -49,4 +49,4 @@ ShowOnAllDesktops=true
ShowSystrayIcon=true
ShowTabBar=true
ShowTitleBar=true
ToggleToFocus=false
ToggleToFocus=false

1
.gitignore vendored
View File

@@ -13,6 +13,7 @@
.config/Code/rapid_render.json
.config/Code/Network*
**/.config/.brightness
.local/share/fonts/.uuid
# Byte-compiled / optimized / DLL files
*__pycache__/

View File

@@ -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