blob: 48999af6e72ffe9dcfb7bff58d42c25dbc6e7a3d (
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# Debian packages: fzf
# If not running interactively, don't do anything else
[ -z "$PS1" ] && return
if [ -f $HOME/.environment ]; then
. $HOME/.environment
fi
export HISTFILESIZE=
export HISTSIZE=
eval `dircolors 2>/dev/null`
# don't put duplicate lines in the history
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
# append to the history file, don't overwrite it
shopt -s histappend
# store multi-line commands in history
shopt -s cmdhist
# this breaks eg "bts show #nnnnnn"
shopt -u interactive_comments
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# Name directory to change to it.
shopt -s autocd
# Disable XOFF, for f*** sake
stty -ixon
# enable completion
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# enable fzf completion if available
if [ -f /usr/share/bash-completion/completions/fzf ]; then
. /usr/share/bash-completion/completions/fzf
fi
if [ -f /usr/share/doc/fzf/examples/key-bindings.bash ]; then
. /usr/share/doc/fzf/examples/key-bindings.bash
fi
# enable local config parts
if [ -d ~/.bash.d/ ]; then
for f in $(find ~/.bash.d/ -type f); do
. $f
done
fi
# aliases
if [ -e ~/.alias.d/ ]; then
for e in $(find ~/.alias.d/ -type l,f | sort); do
. $e
done
fi
umask 022
vterm_printf() {
if [ -n "$TMUX" ] && ([ "${TERM%%-*}" = "tmux" ] || [ "${TERM%%-*}" = "screen" ]); then
# Tell tmux to pass the escape sequences through
printf "\ePtmux;\e\e]%s\007\e\\" "$1"
elif [ "${TERM%%-*}" = "screen" ]; then
# GNU screen (screen, screen-256color, screen-256color-bce)
printf "\eP\e]%s\007\e\\" "$1"
else
printf "\e]%s\e\\" "$1"
fi
}
vterm_prompt_end(){
vterm_printf "51;A$(whoami)@$(hostname):$(pwd)"
}
update_title () {
printf "\e]0;$USER@$HOSTNAME: %s\a" "$1"
}
# Update title before executing a command: set it to the full command
show_command () {
this_command="`history 1`"
update_title "${this_command/+([ ])+([0-9])+([ ])/}"
}
# Things to do before displaying the command prompt, including printing
# nonzero exit status of the last run command, and setting the git branch.
prompt_command_notitle () {
local code="$?"
if [ "$code" -ne 0 ]; then
echo "- exit $code"
fi
local fullbranch="$(cat .git/HEAD 2>/dev/null)"
if [ "$fullbranch" = "" ]; then
local fullbranch="$(git symbolic-ref HEAD 2>/dev/null)"
fi
local branch="${fullbranch##ref: }"
vcsinfo="${branch:+#${branch##refs/heads/}}"
}
prompt_command () {
prompt_command_notitle
update_title
}
PS1='\u@\h:\w$vcsinfo> '
case "$TERM" in
xterm*|rxvt*|screen)
PS1="\[\e]0;\u@\h:\w\a\]$PS1"'\[$(vterm_prompt_end)\]'
trap show_command DEBUG
PROMPT_COMMAND=prompt_command
;;
*)
PS1=$PS1'\[$(vterm_prompt_end)\]'
PROMPT_COMMAND=prompt_command_notitle
;;
esac
PROMPT_DIRTRIM=2
if [ -e ~/.bashrc.post ]; then
. ~/.bashrc.post
fi
|