dotfiles

🎜 Clone'em, tweak'em, stick'em in your $HOME 🎝
git clone https://git.kevinlegouguec.net/dotfiles
Log | Files | Refs | README

commit b3c2ffbf9edbbdd6bd6cb1769543c4093f15f835
parent 25f04e5bff8b3f5d28df0baf647b554657f50b0a
Author: KΓ©vin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Wed,  1 Feb 2023 08:25:47 +0100

Absorb .bashrc bits hoarded from machine to machine for eons

* inputrc goodies,
* let readline see C-s,
* reverse PS4 for kicks,
* protect crippled shells (M-x shell, batch ssh commands) from this
savagery.

Diffstat:
A.bash_inputrc | 5+++++
M.bash_prompt | 48+++++++++++++++++++++++++++++++++---------------
2 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/.bash_inputrc b/.bash_inputrc @@ -0,0 +1,5 @@ +set blink-matching-paren +set colored-completion-prefix on +set colored-stats on +set enable-active-region on +set skip-completed-text diff --git a/.bash_prompt b/.bash_prompt @@ -81,6 +81,7 @@ __fontify () local -A codes=( [bold]=1 [dim]=2 + [reverse]=7 [red]=31 [green]=32 [blue]=34 @@ -204,24 +205,41 @@ __refresh-terminal () __set-prompt } +__init-smart () +{ + ### Prompts. -PS2='… ' + PS2=$(__fontify '… ' dim) + export PS4=$(__fontify "${PS4}" reverse) -if [ "${TERM}" = dumb ] -then - PS1='$? \u:\w\$ ' - return -fi + if __have-gitprompt + then + . /usr/lib/git-core/git-sh-prompt + GIT_PS1_SHOWDIRTYSTATE=t + GIT_PS1_SHOWUPSTREAM=auto -PS2=$(__fontify "${PS2}" dim) + PS1_SHOWGITSTATUS=t + fi -if __have-gitprompt -then - . /usr/lib/git-core/git-sh-prompt - GIT_PS1_SHOWDIRTYSTATE=t - GIT_PS1_SHOWUPSTREAM=auto + PROMPT_COMMAND=__refresh-terminal - PS1_SHOWGITSTATUS=t -fi + ### Bindings. + + bind -f ~/.bash_inputrc -PROMPT_COMMAND=__refresh-terminal + # Unset the TTY's "stop" char, so that readline receives C-s. + if tty -s + then + stty stop '' + fi +} + + +if [ "${TERM}" = dumb ] +then + PS1='$? \u:\w\$ ' + PS2='> ' + export PS4='+ ' +else + __init-smart +fi