-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbashrc
129 lines (98 loc) · 2.92 KB
/
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
# Check dotfiles ~/dotfiles/rc-common.sh if not found in here
# Source file that contains directives that are common to both zshrc and bashrc
dotfiles_path=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
common_source="$dotfiles_path/rc-common.sh"
if [ -e "$common_source" ]; then
. "$common_source"
fi
# Add lua packages to path
if which luarocks>/dev/null; then
eval $(luarocks path)
fi
# Do not source below if not interactive
[[ $- != *i* ]] && return
# ------------------- Interactive shell configuration ---------------------------
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Add Bash autocompletion if available
[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
alias vimrc='nvim ~/dotfiles/nvim/vimrc.vim'
alias nvimrc='nvim ~/dotfiles/nvim/init.lua'
alias bashrc='nvim ~/.bashrc'
alias vim='nvim'
alias ls='ls --color=auto'
ptest() {
nvim --headless -c "PlenaryBustedFile $1"
}
alias luatest=ptest
# Set PS1 if set to default bash ps1
set_ps1() {
if [ -e /etc/bash_completion.d/git-prompt ]; then
source /etc/bash_completion.d/git-prompt
fi
PS1='\u@\h \W\$ '
}
set_ps1
# Unlimited history
HISTSIZE= HISTFILESIZE=
# Change history file location because some programs truncate it
export HISTFILE=~/.bash_external_history
# Immediately append history to file
shopt -s histappend
export PROMPT_COMMAND="${PROMPT_COMMAND}${PROMPT_COMMAND:+;}history -a; history -n"
# Add a local rc file for configurations specific to this machine
# XXX needs to be at end
[[ -f ~/.bashrc.local ]] && . ~/.bashrc.local
# Autocomplete tab select for interactive
if [[ $- = *i* ]]; then
bind '"\t":menu-complete'
bind "set show-all-if-ambiguous on"
bind "set completion-ignore-case on"
bind "set menu-complete-display-prefix on"
fi
# Display terminal colors
colors() {
local fgc bgc vals seq0
printf "Color escapes are %s\n" '\e[${value};...;${value}m'
printf "Values 30..37 are \e[33mforeground colors\e[m\n"
printf "Values 40..47 are \e[43mbackground colors\e[m\n"
printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n"
# foreground colors
for fgc in {30..37}; do
# background colors
for bgc in {40..47}; do
fgc=${fgc#37} # white
bgc=${bgc#40} # black
vals="${fgc:+$fgc;}${bgc}"
vals=${vals%%;}
seq0="${vals:+\e[${vals}m}"
printf " %-9s" "${seq0:-(default)}"
printf " ${seq0}TEXT\e[m"
printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"
done
echo; echo
done
}
pdroid() {
ansible-playbook -l odroid -i inventory.yml $@
}
sb() {
source ~/.bashrc
}
dockerlastid() {
ret="$(sudo docker ps | awk '{ print $1 }' | tail -n 1)"
if [[ "$ret" == "CONTAINER" ]]; then
echo NO CONTAINERS
return 1
fi
echo "$ret"
}
if [ -e /home/bryce/.cargo/bin ]; then
export PATH="$PATH:/home/bryce/.cargo/bin"
fi
# Find and replace
fr() {
sd "$1" "$2" $(ag "$1" --files-with-matches)
}