54
.blerc
Normal file
54
.blerc
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user