-
Notifications
You must be signed in to change notification settings - Fork 5
/
.bashrc
executable file
·171 lines (135 loc) · 3.96 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/bash
# For interactively-running bash terminals.
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# Import from the global blob
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
## Helpers
prepend_path_if_exists() {
if [ ! -z "$1" ] && [ -d "$1" ]; then
# Add $2 if provided, otherwise use $1
export PATH="${2:-$1}:$PATH"
fi
}
# Check what we're running on.
[[ `uname -a | grep -ic 'linux'` -gt 0 ]] && export IS_LINUX=1
[[ `uname -a | grep -ic 'darwin'` -gt 0 ]] && export IS_MAC=1
## Setup scripts
# asdf
if [ -f "$HOME/.asdf/asdf.sh" ]; then
. "$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"
fi
if [ -f "/usr/local/opt/asdf/asdf.sh" ]; then
. "/usr/local/opt/asdf/asdf.sh"
fi
if [ -f "/opt/homebrew/opt/asdf/libexec/asdf.sh" ]; then
. "/opt/homebrew/opt/asdf/libexec/asdf.sh"
fi
# Rust/Cargo
if [ -f "$HOME/.cargo/env" ]; then
. "$HOME/.cargo/env"
fi
# Node.js
if [ -d "$HOME/.nvm" ]; then
export NVM_DIR="$HOME/.nvm"
. "/usr/local/opt/nvm/nvm.sh"
#nvm use 8 2>/dev/null >/dev/null
fi
## Plain $PATH manip
# Node.js
prepend_path_if_exists "$HOME/node_modules/.bin"
# Python
prepend_path_if_exists "$HOME/env/bin"
# Haskell
prepend_path_if_exists "$HOME/.local/bin" # Stack
prepend_path_if_exists "$HOME/.cabal" "$HOME/.cabal-sandbox/bin:$HOME/.cabal/bin"
# Set PATH so it includes user's private bin if it exists
prepend_path_if_exists "$HOME/bin"
prepend_path_if_exists "$HOME/build/bin"
# Misc
prepend_path_if_exists "/opt/blender"
prepend_path_if_exists "$HOME/.platformio/penv/bin"
# History
# No duplicate blanks lines
HISTCONTROL=ignoredups:ignorespace
# Append, don't overwrite
shopt -s histappend
HISTSIZE=5000
HISTFILESIZE=10000
# Misc preferences
export EDITOR=$(command -v nvim)
export LESS="R" # Have 'less' interpret/use colour codes
#export TERM=xterm-256color
if [ $IS_MAC ]; then
export GREP_OPTIONS="--color=auto"
fi
if [ $IS_MAC ]; then
export CLICOLOR=1
fi
# Check the window size after each command and, if necessary,
# Update the values of LINES and COLUMNS.
shopt -s checkwinsize
# Make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# Aliases to import
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# Programmable bash completion
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
## Git
# Git Prompt
. ~/.git-completion.bash
export PS1='robin:\w$(__git_ps1 " (%s)")\$ '
export PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}\007"'
# Hook installation
export GIT_TEMPLATE_DIR="$(undercommit template-dir)"
# Elixir
export ERL_AFLAGS="-kernel shell_history enabled"
# Set STDERR text to red
#if [ -f "$HOME/lib/stderred.so" ]; then
# export LD_PRELOAD="$HOME/lib/stderred.so"
#fi
# Load in anything else that's install-specific.
if [ -d "$HOME/.bashrc.d" ]; then
shopt -s nullglob
for FILE in "$HOME/.bashrc.d/"*; do
source "${FILE}"
done
shopt -u nullglob
fi
# ripgrep config
export RIPGREP_CONFIG_PATH="$HOME/.ripgreprc"
# SSH Agent
SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS="-s"
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
eval `$SSHAGENT $SSHAGENTARGS`
trap "kill $SSH_AGENT_PID" 0
fi
# Homebrew
if [ -f "/opt/homebrew/bin/brew" ]; then
eval $(/opt/homebrew/bin/brew shellenv)
# Stop homebrew removing everything all the bloody time
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
fi
# Alias 'thefuck' to something more pleasant.
eval $(thefuck --alias "please")
# AWS
export SAM_CLI_TELEMETRY=0
# MacOS Bash warning
export BASH_SILENCE_DEPRECATION_WARNING=1
# z
# Most 'frecent' directories, eg.
# $ z foo cd to most frecent dir matching foo
# $ z foo bar cd to most frecent dir matching foo, then bar
# $ z -r foo cd to highest ranked dir matching foo
# $ z -t foo cd to most recently accessed dir matching foo
# $ z -l foo list all dirs matching foo (by frecency)
. ~/bin/z.sh
#export PATH="$HOME/.platformio/penv/bin:$PATH"