-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_bashrc.tmpl
111 lines (89 loc) · 3.05 KB
/
dot_bashrc.tmpl
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
#!/usr/bin/env bash
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
command set -o vi
command set -o ignoreeof
command set -o noclobber
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
# shellcheck disable=SC1090,SC1091
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
# shellcheck disable=SC1090,SC1091
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
{{ if eq .chezmoi.os "darwin" -}}
(command -v brew > /dev/null ) && {
HOMEBREW_PREFIX="$(brew --prefix)"
if [[ -r "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh" ]]; then
# shellcheck disable=SC1091
source "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh"
else
for COMPLETION in "${HOMEBREW_PREFIX}/etc/bash_completion.d/"*; do
# shellcheck disable=SC1090
[[ -r "$COMPLETION" ]] && source "$COMPLETION"
done
fi
}
{{ end -}}
if [ -f ~/.bash_prompt ]; then
# shellcheck disable=SC1090,SC1091
. ~/.bash_prompt
fi
export EDITOR=vi
export VISUAL=vi
(command -v vim > /dev/null 2>&1) && {
export EDITOR=vim
export VISUAL=vim
}
(command -v direnv > /dev/null 2>&1) && eval "$(direnv hook bash)"
{{ with (index . "user") }}{{ with (index . "tz") }}
export TZ='{{ . }}'
{{ end }}{{ end }}
export LC_ALL="en_US.UTF-8" > /dev/null 2>&1
export LANG="en_US.UTF-8"
export LESSCHARSET='UTF-8'
export LESS='-FeX2Rgmwz-2'
export PAGER=less
# shellcheck disable=SC1090
[ -f "${HOME}/.local.bashrc" ] && source "${HOME}/.local.bashrc"
function start_ssh_agent() {
# shellcheck disable=SC1090,SC1091
(command -v ssh-agent > /dev/null 2>&1) && {
[ -f "${HOME}/.ssh/agent.pid" ] && source "${HOME}/.ssh/agent.pid" >/dev/null 2>&1
if [ -z "${SSH_AGENT_PID}" ] || [ "$(ps -p "${SSH_AGENT_PID}" -o comm=)" != "ssh-agent" ]; then
echo "cleanup and restart ssh-agent"
[ -f "${HOME}/.ssh/agent.pid" ] && rm -f "${HOME}/.ssh/agent.pid"
ssh-agent >"${HOME}/.ssh/agent.pid"
source "${HOME}/.ssh/agent.pid"
fi
}
}
[ ! -f "{{ .chezmoi.homeDir }}/.ssh/noagent" ] && start_ssh_agent || true