-
Notifications
You must be signed in to change notification settings - Fork 1
/
dot_bashrc
148 lines (124 loc) · 4.47 KB
/
dot_bashrc
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# shellcheck disable=SC2148
# ~/.bashrc: executed by bash(1) for non-login shells.
if [ -z "$PS1" ]; then
# If not running interactively, don't do anything
return
fi
unset CDPATH
export HOSTFILE=$HOME/.hosts # Put list of remote hosts in ~/.hosts
export PAGER="less"
export LESS="-I -j6 -M -F -X -R"
#
# Shell opts: see bash(1)
#
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
shopt -s cdable_vars # if cd arg fail, assumes its a var defining a dir
shopt -s cdspell # autocorrects cd misspellings
shopt -s cmdhist # save multi-line commands in history as single line
shopt -s expand_aliases # expand aliases
shopt -s extglob # enable extended pattern-matching features
shopt -s checkhash
shopt -s dirspell
shopt -s no_empty_cmd_completion
shopt -s dotglob # include dotfiles in pathname expansion
shopt -s hostcomplete # attempt hostname expansion when @ is at the beginning of a word
#shopt -s nocaseglob # pathname expansion will be treated as case-insensitive
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
use_color=true
# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS. Try to use the external file
# first to take advantage of user additions. Use internal bash
# globbing instead of external grep binary.
safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM
match_lhs=""
[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs} ]] &&
type -P dircolors >/dev/null &&
match_lhs=$(dircolors --print-database)
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true
if ${use_color}; then
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489
if type -P dircolors >/dev/null; then
if [[ -f ~/.dir_colors ]]; then
eval "$(dircolors -b ~/.dir_colors)"
elif [[ -f /etc/DIR_COLORS ]]; then
eval "$(dircolors -b /etc/DIR_COLORS)"
fi
fi
if [[ ${EUID} == 0 ]]; then
PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\]\n$ '
else
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\n$ '
#PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
fi
alias ls='ls -hF --color=always --group-directories-first'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
else
if [[ ${EUID} == 0 ]]; then
# show root@ when we don't have colors
# PS1='\u@\h \W \$ '
PS1='[\u@\h:\W] '
else
#PS1='\u@\h \w \$ '
PS1='[\u@\h:\w] '
fi
fi
# Try to keep environment pollution down, EPA loves us.
unset use_color safe_term match_lhs
if [ -n "$DISPLAY" ] && [ "$TERM" == "xterm" ] &&
[ -e /usr/share/terminfo/x/xterm-256color ]; then
export TERM=xterm-256color
fi
# Turn off annoying and useless flow control keys
stty -ixon
# debug bash script
debug() {
local script="$1"
shift
bash -x "$(command -v "$script")" "$@"
}
# set PATH so it includes user's private bin if it exists
if [ -d ~/bin ]; then
PATH=~/bin:"${PATH}"
fi
#
# Other Alias
#
alias ll='ls -l'
# safety features
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
alias e=vim
export EDITOR='vim'
alias ..='cd ..'
export PATH=$HOME/.local/share/zinit/plugins/tmux/:$PATH
if (command -v keychain >/dev/null 2>&1); then
if [[ -f "$HOME/.ssh/id_rsa" ]]; then
eval "$(keychain --eval --quiet --agents ssh id_rsa)"
fi
fi
#
# History Stuff
#
export HISTTIMEFORMAT="%H:%M > "
HISTIGNORE='&:[bf]g:ll:h:ls:clear:exit:\&:pwd:up:cd ..:'
HISTIGNORE=${HISTIGNORE}':cd ~-:cd -:cd:jobs:set -x:ls -l:top'
HISTIGNORE=${HISTIGNORE}':%1:%2:popd:top:halt:shutdown:reboot*'
export HISTIGNORE
shopt -s histreedit # reedit a history substitution line if it failed
shopt -s histverify # edit a recalled history line before executing
shopt -s histappend # append new history items to .bash_history
export HISTCONTROL=ignoreboth:erasedups:ignorespace
export HISTFILESIZE=10000 # increase history file size (default is 500)
export HISTSIZE=${HISTFILESIZE} # increase history size (default is 500)
# ensure synchronization between Bash memory and history file
export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
# vim:ft=bash ts=4 sw=4