-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.bashrc
More file actions
executable file
·204 lines (162 loc) · 4.91 KB
/
.bashrc
File metadata and controls
executable file
·204 lines (162 loc) · 4.91 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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/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
# mise
if [ -f "$HOME/.local/bin/mise" ]; then
eval "$("$HOME/.local/bin/mise" activate bash)"
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"
export PATH="$PATH:node_modules/.bin"
# - Bun
export BUN_INSTALL="$HOME/.bun"
prepend_path_if_exists "$BUN_INSTALL/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"
# MacOS GNU
prepend_path_if_exists "/opt/homebrew/opt/grep/libexec/gnubin"
prepend_path_if_exists "/opt/homebrew/opt/binutils/bin"
# Misc Homebrew keg-only libs
prepend_path_if_exists "/opt/homebrew/opt/icu4c/bin"
prepend_path_if_exists "/opt/homebrew/opt/icu4c/sbin"
# Ruby-build with Mise
prepend_path_if_exists "/usr/local/opt/ruby/bin"
# Misc
prepend_path_if_exists "/opt/blender"
prepend_path_if_exists "$HOME/.platformio/penv/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"
# History
# No duplicate blanks lines
HISTCONTROL=ignoredups:ignorespace
# Append, don't overwrite
shopt -s histappend
HISTSIZE=5000
HISTFILESIZE=10000
# 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
# Homebrew completions
#if [ -d /opt/homebrew/etc/bash_completion.d ] && ! shopt -oq posix; then
# for ii in /opt/homebrew/etc/bash_completion.d/*; do
# . "$ii"
# done
#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
# 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
# and this
export HOMEBREW_NO_AUTO_UPDATE=true
# Fixing a diesel-cli install for Rust
#export DYLD_LIBRARY_PATH="/opt/homebrew/lib:$DYLD_LIBRARY_PATH"
# ... which causes problems for some homebrew apps. yay.
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"
# 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
# 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