summaryrefslogtreecommitdiff
path: root/config/bash/bashrc
diff options
context:
space:
mode:
Diffstat (limited to 'config/bash/bashrc')
-rw-r--r--config/bash/bashrc37
1 files changed, 31 insertions, 6 deletions
diff --git a/config/bash/bashrc b/config/bash/bashrc
index ca2435d..9f12e54 100644
--- a/config/bash/bashrc
+++ b/config/bash/bashrc
@@ -1,18 +1,43 @@
-# Minimal bash config for servers
+# Minimal bashrc meant 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
-alias vi=vim
-alias vi=nvim
+# 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'
-PS1='\e[01;31m$(code=${?##0};echo ${code:+[${code}]" "})\e[00m\u@\H \w % '
+stty -ixon # Disable ctrl-s and ctrl-q for freezing prompt
+shopt -s autocd # Automatically cd into typed directory
+
+PS1='\[\e[01;31m\]$(code=$?; [ "$code" -ne 0 ] && echo "[${code}] ")\[\e[00m\]\[\e[01;34m\]\u\[\e[00m\]@\H \w % '
+
+# Source bash completion
+for bc in /etc/bash_completion /usr/share/bash-completion/bash_completion; do
+ [ -f "$bc" ] && . "$bc"
+done
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 \
+ claer="clear -x" \
+ clear="clear -x" \
+ clera="clear -x" \
+ lf="lfcd" \
+ vi="nvim" \
+ vi="vim"
+
fi
if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/functionrc" ];then
source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/functionrc"
+else
+ lfcd () {
+ cd "$(command lf -print-last-dir "$@")"
+ }
fi
+
+bind '"\C-o": "\C-ulfcd\n"'