summaryrefslogtreecommitdiff
path: root/config/bash/bashrc
blob: a4b497f572b3d8083cdb7dd4696bf68cb8b71044 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Minimal bashrc meant for servers

set -o vi
# `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'

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 % '

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"'