-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_bashrc
More file actions
128 lines (106 loc) · 3.2 KB
/
Copy pathdot_bashrc
File metadata and controls
128 lines (106 loc) · 3.2 KB
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
# do nothing if non-interactive
[[ $- != *i* ]] && return
# appends to the histfile instead of overwriting
shopt -s histappend
# bash should check the window size after every command
shopt -s checkwinsize
# bash matches filenames in a case-insensitive fashion when performing
# pathname expansion
shopt -s nocaseglob
# allows recursive matching in cd via ** (if supported)
shopt -s autocd 2> /dev/null
# allows recursive globbing via **
shopt -s globstar 2> /dev/null
# minor errors in the spelling of a directory component in a cd command will
# be corrected
shopt -s cdspell
# ls
case $(uname) in
Darwin)
export CLICOLOR_FORCE=1
alias ls="\ls -bCFGh"
alias ll="\ls -bCFGh -l"
alias la="\ls -bCFGh -la"
;;
Linux)
alias ls="\ls --color=always -bCFh"
alias ll="\ls --color=always -bCFh -l"
alias la="\ls --color=always -bCFh -la"
;;
esac
# less
export LESS="-FRXi"
# lesspipe
if command -v lesspipe &>/dev/null; then
eval $(lesspipe) &>/dev/null
elif command -v lesspipe.sh &>/dev/null; then
export LESSOPEN="| $(command -v lesspipe.sh) %s"
export LESS_ADVANCED_PREPROCESSOR=1
elif command -v src-hilite-lesspipe.sh &>/dev/null; then
export LESSOPEN="| src-hilite-lesspipe.sh %s"
elif [[ -f /usr/share/source-highlight/src-hilite-lesspipe.sh ]]; then
export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s"
fi
# man
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
# screen and tmux
command -v screen &>/dev/null && alias scr="screen -d -RR"
alias t="tmux new -A -D -s main"
# prompt
prompt_host="\h"
# suffix depends on identity
if [[ $(id -u) == 0 ]]; then
# pound for root
prompt_suffix="#"
else
# symbol otherwise
prompt_suffix=">"
fi
# colors
start_host_color="\[\e[1;31m\]"
end_host_color="\[\e[m\]"
start_pwd_color="\[\e[1;34m\]"
end_pwd_color="\[\e[m\]"
export PS1="${start_host_color}${prompt_host}${end_host_color}:${start_pwd_color}\w${end_pwd_color} ${prompt_suffix} "
# prompt command for use in screen multiplexer
case $TERM in
screen)
export PROMPT_COMMAND='echo -n -e "\033k\033\\"'
;;
esac
# direnv
if command -v direnv &>/dev/null; then
eval "$(direnv hook bash)"
export DIRENV_LOG_FORMAT=
fi
# fzf
if command -v fzf &>/dev/null && [[ $- == *i* ]]; then
eval "$(fzf --bash)"
fi
# zoxide
command -v zoxide &>/dev/null && eval "$(zoxide init --cmd j bash)"
# completion; this runs only on 4+
if (( $BASH_VERSINFO >= 4 )); then
case $(uname) in
Darwin)
[[ -r "$(brew --prefix)/etc/profile.d/bash_completion.sh" ]] && . "$(brew --prefix)/etc/profile.d/bash_completion.sh"
;;
Linux)
[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \
. /usr/share/bash-completion/bash_completion
;;
esac
fi
# shellcheck source=/dev/null
# sources local bashrc
[[ -r ~/.bashrc-local ]] && . ~/.bashrc-local