diff options
| Commit | 2d0e6cf575b377bc8b1f63b08dfc9a558ac2bb20 (patch) | |
|---|---|---|
| Author | 2025-12-31 11:12:13 +0200 | |
| Committer | 2025-12-31 11:12:13 +0200 | |
| Files | 8dd7f7e60bf2ae9f584e4000274f1206f77091de | |
| .files-2d0e6cf575b377bc8b1f63b08dfc9a558ac2bb20.tar .files-2d0e6cf575b377bc8b1f63b08dfc9a558ac2bb20.tar.gz .files-2d0e6cf575b377bc8b1f63b08dfc9a558ac2bb20.zip | ||
| Parent | 44762cffb6fcf52b68d898e4c521e38c2bbe60e0 (diff) | |
fix(.bashrc)!: Compatibility with readline 8.3 and bash 5.3
1 files changed, 34 insertions, 15 deletions
| -rw-r--r-- | .bashrc | 49 |
@@ -85,14 +85,23 @@ export PROMPT_COMMAND="shell_var_fix;" hc_mode && PS_INFO=97 || PS_INFO=45 hc_mode && PS_DBG=52 || PS_DBG=41 - hc_mode && PS_TRIANGLE='' || PS_TRIANGLE='|' - hc_mode && PS_TRIANGLE_BOT='' || PS_TRIANGLE='|' - hc_mode && PS_LEFT_SEMI='' || PS_LEFT_SEMI='(' - hc_mode && PS_LEFT_SLAB='█' || PS_LEFT_SLAB='| ' - hc_mode && PS_RIGHT_SLAB='█' || PS_RIGHT_SLAB=' |' - hc_mode && PS_RIGHT_SEMI='' || PS_RIGHT_SEMI=')' - hc_mode && PS_PREC='' || PS_PREC='>' - hc_mode && PS_PREC_GIT='' || PS_PREC_GIT='{}' + # From readline 8.3 (+ patch 1), multibyte characters are + # counted differently: every byte is counted as contributing + # to the length of the line. So, the hc_mode unicode symbols + # are counted as 2+ characters, instead of as 1. + # As a workaround, we're making the unicode chars non-visible + # with \001 and \002, which makes them count as 0 chars, + # and then we add a blank character (\024 is 20, "Device Control 4") + # which doesn't (sometimes?) visually appear but is counted as + # 1 character. + hc_mode && PS_TRIANGLE="\001\002\024" || PS_TRIANGLE='|' + hc_mode && PS_TRIANGLE_BOT="\001\002\024" || PS_TRIANGLE='|' + hc_mode && PS_LEFT_SEMI="\001\002\024" || PS_LEFT_SEMI='(' + hc_mode && PS_LEFT_SLAB="\001█\002\024" || PS_LEFT_SLAB='| ' + hc_mode && PS_RIGHT_SLAB="\001█\002\024" || PS_RIGHT_SLAB=' |' + hc_mode && PS_RIGHT_SEMI="\001\002\024" || PS_RIGHT_SEMI=')' + hc_mode && PS_PREC="\001\002\024" || PS_PREC='>' + hc_mode && PS_PREC_GIT="\001\002\024" || PS_PREC_GIT='{}' ___dirchanged="" @@ -341,10 +350,6 @@ EOF # }}} # Processes {{{ - fg() { - builtin fg >/dev/null - } - # Run in the background bgr() { nohup sh -c "$@" >~/nohup.out 2>&1 & @@ -398,9 +403,23 @@ EOF if [[ $- =~ i ]] then bind '"\C-l":clear-screen' - bind -x '"\C-g":lazygit' - bind -x '"\C-f":fg' - bind '"\C-h": backward-kill-word' + bind '"\C-h":backward-kill-word' + + bind -x '"\xC0\021":lazygit' + bind '"\C-g":"\xC0\021\n"' + + # From readline 8.3 (+ patch 1) or bash 5.3 (+ patch 3) + # something changed and now, if you do Ctrl-Z after Ctrl-F, + # the readline input breaks. The only way I've found to fix + # it is via accepting the current line (bound to \n). + # To make the output less cluttered, I also go up two lines. + fgrl() { + builtin fg >/dev/null + printf "\e[2A" + } + + bind -x '"\xC0\022":fgrl' + bind '"\C-f":"\xC0\022\n"' fi # }}} |
