blob: bfba6d41ce6e61415091dc0278874288d560e26d (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# ~/.bashrc: executed by bash(1) for non-login shells.
# I include this file for all interactive invocations of bash(1), whether
# they are login shells or not.
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# set variable identifying the chroot you work in (used in the prompt below)
if [[ -z "$debian_chroot" ]] && [[ -r /etc/debian_chroot ]]; then
debian_chroot="$(cat /etc/debian_chroot)"
fi
# Why is this not on by default?
# "We have a cached value, but it isn't valid anymore. Should we trash it?"
# "Duh, yes!"
shopt -s checkhash
################################################################################
# History settings
export HISTCONTROL=ignoredups
export HISTFILE=${XDG_CACHE_HOME}/bash/history
export HISTTIMEFORMAT='[%Y-%m-%d %H:%M] '
shopt -s histappend # append to the history file, don't overwrite it
mkdir -p "${HISTFILE%/*}"
# General settings
shopt -s checkwinsize # update the values of LINES and COLUMNS
shopt -s globstar # Let ** recursively scan directories
PROMPT_COMMAND=''
################################################################################
# Overly complicated setting of PS1 #
################################################################################
# Belongs in aliases, but I use it here
term-title() {
local fmt=''
case "$TERM" in
screen|tmux) fmt='\ek%s\e\\';;
xterm*|rxvt*) fmt='\e]0;%s\a';;
esac
printf "$fmt" "$*"
}
make_prompt() {
local _CHROOT='${debian_chroot:+($debian_chroot)}'
echo "${BOLD}${_CHROOT}${GREEN}\u@\h${RESET}${BOLD}${BLUE}:\w${RESET}"
}
if [[ -x /usr/bin/tput ]] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
RESET="$(tput sgr0)"
BOLD="$(tput bold)"
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
BLUE="$(tput setaf 4)"
_STATUS="${BOLD}["
_STATUS+='$(v=$?; if [[ $v = 0 ]]; then c='"'${GREEN}'"'; else c='"${RED}"'; fi; printf %s%03i $c $v)'
_STATUS+="${RESET}${BOLD}]${RESET}"
else
_STATUS='[$?]'
fi
PS1="${_STATUS} $(make_prompt)"'\n\$ '
unset RESET BOLD RED GREEN BLUE _STATUS use_color
PS1="$(term-title $(make_prompt))$PS1"
unset make_prompt
################################################################################
# Load my alaises
if [[ -f ${XDG_CONFIG_HOME}/bash/aliases.sh ]]; then
. ${XDG_CONFIG_HOME}/bash/aliases.sh
fi
# Include modular config files
if [[ -d ${XDG_CONFIG_HOME}/bash/rc.d ]]; then
for file in "${XDG_CONFIG_HOME}/bash/rc.d"/*.sh; do
. "$file"
done
fi
|