diff options
author | Suleyman Farajli <suleyman@farajli.net> | 2025-06-19 00:50:57 +0400 |
---|---|---|
committer | Suleyman Farajli <suleyman@farajli.net> | 2025-06-19 00:50:57 +0400 |
commit | 5a339d2f6c9fda89b586f8c4839d466e491076b5 (patch) | |
tree | 069104bd1383ef4ab2db0d235bdc8525aa4f50b1 | |
parent | 88118fec7dc683e1c8af9c3038eab6fca9a68126 (diff) |
refactor: improve minimal bash config for vi mode and portability
- Add manual bindings for Ctrl-l in vi normal/insert mode
- Improve PS1 prompt with exit code handling and color
- Comment out slow vi mode indicator suggestion
- Add fallback clear alias and remove duplicate vi alias
-rw-r--r-- | config/bash/bashrc | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/config/bash/bashrc b/config/bash/bashrc index ca2435d..f143fd2 100644 --- a/config/bash/bashrc +++ b/config/bash/bashrc @@ -1,18 +1,28 @@ -# Minimal bash config for servers - set -o vi -stty -ixon # Disable ctrl-s and ctrl-q for freezing prompt -shopt -s autocd # automatically cd into typed directory +# `set show-mode-in-prompt on` is not set, +# indicating vi mode in bash is too slow + +# Ctrl-l is disabled in vi mode, bind it manually +bind -m vi-command '"\C-l": clear-screen' +bind -m vi-insert '"\C-l": clear-screen' -alias vi=vim -alias vi=nvim +stty -ixon # Disable ctrl-s and ctrl-q for freezing prompt +shopt -s autocd # Automatically cd into typed directory -PS1='\e[01;31m$(code=${?##0};echo ${code:+[${code}]" "})\e[00m\u@\H \w % ' +PS1='\[\e[01;31m\]$(code=$?; [ "$code" -ne 0 ] && echo "[${code}] ")\[\e[00m\]\[\e[01;34m\]\u\[\e[00m\]@\H \w % ' if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" ];then source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" +else + # Fallback aliases where aliasrc isn't present (e.g., on servers) + alias \ + vi="vim" \ + vi="nvim" \ + clear="clear -x" + fi if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/functionrc" ];then source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/functionrc" + bind '"\C-o": "\C-ulfcd\n"' fi |