-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_bashrc
148 lines (114 loc) · 3.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
# vim:ft=bash
export TERM=xterm-256color
export SHELL=bash
prompt_env() {
prompt_jobs=$(jobs | wc -l)
prompt_branch=$(hg branch 2> /dev/null | awk -- '{print "on "$1}')
PS1="\[\e[36m\]\A \[\e[1;34m\]\[\e[31m\]\H\[\e[1;34m\] \w\[\e[0m\] \[\e[32m\]$prompt_branch\[\e[0m\]\n$prompt_jobs > \[\e[0m\]"
}
PROMPT_COMMAND=prompt_env
PS1="\[\e[36m\]\A \[\e[1;34m\]\[\e[31m\]\H\[\e[1;34m\] \w\[\e[0m\] \[\e[32m\]$prompt_branch\[\e[0m\]\n$prompt_jobs > \[\e[0m\]"
alias ls="ls"
alias ll="ls -lAvhtr --color"
alias l=ll
alias fgrep='fgrep -nrI --color --exclude-dir=.hg --exclude=*.log --exclude=*.dup --exclude=*.orig --exclude=transcript --exclude=tags --exclude=Session.vim'
alias xclip='xclip -selection clipboard'
alias mvim=gvim
export HISTCONTROL=erasedups
export HISTSIZE=10000
export HISTFILESIZE=20000
shopt -s histappend
shopt -s cmdhist
export HISTINGORE="pwd:ls:history"
export XDG_CONFIG_HOME=$HOME/.config
PATH=$HOME/bin:$PATH
PATH=$HOME/.cargo/bin:$PATH
PATH=$HOME/.local/bin:$PATH
PATH=$HOME/.npm-global/bin:$PATH
cd_func ()
{
local x2 the_new_dir adir index
local -i cnt
if [[ $1 == "--" ]]; then
dirs -v
return 0
fi
the_new_dir=$1
[[ -z $1 ]] && the_new_dir=$HOME
if [[ ${the_new_dir:0:1} == '-' ]]; then
#
# Extract dir N from dirs
index=${the_new_dir:1}
[[ -z $index ]] && index=1
adir=$(dirs +$index)
[[ -z $adir ]] && return 1
the_new_dir=$adir
fi
#
# '~' has to be substituted by ${HOME}
[[ ${the_new_dir:0:1} == '~' ]] && the_new_dir="${HOME}${the_new_dir:1}"
#
# Now change to the new dir and add to the top of the stack
pushd "${the_new_dir}" > /dev/null
[[ $? -ne 0 ]] && return 1
the_new_dir=$(pwd)
#
# Trim down everything beyond 11th entry
popd -n +11 2>/dev/null 1>/dev/null
#
# Remove any other occurence of this dir, skipping the top of the stack
for ((cnt=1; cnt <= 10; cnt++)); do
x2=$(dirs +${cnt} 2>/dev/null)
[[ $? -ne 0 ]] && return 0
[[ ${x2:0:1} == '~' ]] && x2="${HOME}${x2:1}"
if [[ "${x2}" == "${the_new_dir}" ]]; then
popd -n +$cnt 2>/dev/null 1>/dev/null
cnt=cnt-1
fi
done
return 0
}
cd_min () {
cd -$1
}
_cd_min() {
local cur opts
cur="${COMP_WORDS[COMP_CWORD]}"
opts=$(dirs -v)
COMPREPLY=($(compgen -W "${opts}" --${cur}))
}
complete -F _cd_min cd_min
alias cd=cd_func
alias psm='/bin/ps -u $USER --sort pgid,time,size,time,pcpu -o pid,pgid,state,user,start_time,time,size:9,pcpu,command --forest'
export EDITOR=nvim
export HGEDITOR=nvim
export RIPGREP_CONFIG_PATH=$HOME/.config/ripgrep/ripgreprc
export BAT_CONFIG_PATH=$HOME/.config/bat/config
stty > /dev/null
# Options
shopt -s globstar
shopt -s autocd
shopt -s cdspell
shopt -s dirspell
shopt -s histverify
shopt -s nocaseglob
shopt -s direxpand
set -o vi
# Load mercurial autocompletion
if [ -f /etc/bash_completion ]; then
source /etc/bash_completion
fi
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
export FZF_DEFAULT_COMMAND='ag -g ""'
source ~/.config/bash/fzf_aliases
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[ -f ~/.bashrc.local ] && source ~/.bashrc.local
# Must run after local paths are added
export SUDO_EDITOR=$(which nvim)
if [ ! -f ~/.lscolors.parsed.sh ]; then
echo 'Generating ls colors'
dircolors --sh ~/.lscolors > ~/.lscolors.parsed.sh
fi
source ~/.lscolors.parsed.sh