-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.bash_profile
189 lines (136 loc) · 6.19 KB
/
.bash_profile
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
#!/usr/bin/env bash
#--------
# EXPORTS
#--------
# Make vim the default editor.
export EDITOR='vim'
# Increase Bash history size. Allow 32³ entries; the default is 500.
export HISTSIZE='32768';
export HISTFILESIZE="${HISTSIZE}";
# Omit duplicates and commands that begin with a space from history.
export HISTCONTROL='erasedups:ignoreboth';
# Don't record some commands
export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history:clear"
# Prefer US English and use UTF-8.
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
# Highlighting inside manpages and elsewhere.
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
export LESS_TERMCAP_md=$'\E[01;38;5;74m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # end mode
export LESS_TERMCAP_se=$'\E[0m' # end standout-mode
export LESS_TERMCAP_so=$'\E[38;5;246m' # begin standout-mode - info box
export LESS_TERMCAP_ue=$'\E[0m' # end underline
export LESS_TERMCAP_us=$'\E[04;38;5;146m' # begin underline
#--------
# PATHS
#--------
# Build, dedupe and then export PATH.
PATH="$PATH:node_modules/.bin:vendor/bin"
PATH="$PATH:$HOME/.node-global-modules/bin"
PATH="$PATH:$HOME/.rbenv/bin"
PATH="$PATH:$HOME/.bin"
# Set PATH, MANPATH, etc., for Homebrew.
eval "$(/opt/homebrew/bin/brew shellenv)"
# Dedupe using awk.
if hash awk 2>/dev/null; then
PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++{if (NR > 1) printf ORS; printf $a[$1]}')
fi;
export PATH
if [ -f ~/.localrc ]; then
. ~/.localrc
fi
#--------
# ALIASES
#--------
# Rails
alias be="bundle exec "
alias gitlog="git reflog --pretty=raw | tig --pretty=raw"
# Show/hide hidden files in Finder
alias showhidden="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hidehidden="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
alias fix='echo -e "\033c" ; stty sane; setterm -reset; reset; tput reset; clear'
# Reload the shell (i.e. invoke as a login shell)
alias reloadbash="exec ${SHELL} -l"
# Always use color output for `ls`
if hash gls 2>/dev/null; then
# use gls from gnu coreutils
colorflag="--color"
export LS_COLORS='no=00:fi=00:di=01;31:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
eval $(gdircolors -b "$HOME/.dircolors")
alias ls="command gls ${colorflag}"
else
# use good old bsd ls
colorflag="-G"
export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx'
alias ls="command ls ${colorflag}"
fi;
# List all files colorized
alias ll="ls -la ${colorflag}"
# Always enable colored `grep` output
# Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage.
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# Recursively delete `.DS_Store` files
alias dscleanup="find . -type f -name '*.DS_Store' -ls -delete"
#--------
# FUNCTIONS
#--------
# grep by file name
ff(){
find . | grep $@
}
# `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring
# the `.git` directory, listing directories first. The output gets piped into
# `less` with options to preserve color and line numbers, unless the output is
# small enough for one screen.
function tre() {
tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX;
}
# ------
# Bash Prompt Invitation
# ------
# <new line><user>:<current_directory> git_branch <new line> <prompt>
export PS1="\n\u:\w \[\e[1;32m\]\$(__git_ps1 '%s')\[\e[0m\] \n→ "
# Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt
shopt -s expand_aliases
# Case-insensitive globbing (used in pathname expansion).
shopt -s nocaseglob
# Append to the Bash history file, rather than overwriting it.
shopt -s histappend
# Save multi-line commands as one command.
shopt -s cmdhist
# Autocorrect typos in path names when using `cd`.
shopt -s cdspell
# Autocorrect on directory names to match a glob.
shopt -s dirspell 2> /dev/null
# ---------------
# BASH COMPLETION
# ---------------
# Enable history expansion with space.
# e.g. typing !!<space> will replace the !! with your last command
bind Space:magic-space
[[ -r "$(brew --prefix)/etc/profile.d/bash_completion.sh" ]] && . "$(brew --prefix)/etc/profile.d/bash_completion.sh"
[[ -r "$(brew --prefix)/etc/bash_completion.d/brew" ]] && . "$(brew --prefix)/etc/profile.d/bash_completion.sh"
[[ -r "$(brew --prefix)/etc/bash_completion.d/rg.bash" ]] && . "$(brew --prefix)/etc/bash_completion.d/rg.bash"
[[ -r "$(brew --prefix)/etc/bash_completion.d/git-completion.bash" ]] && . "$(brew --prefix)/etc/bash_completion.d/git-completion.bash"
[[ -r "$(brew --prefix)/etc/profile.d/z.sh" ]] && . "$(brew --prefix)/etc/profile.d/z.sh"
[[ -r "$(brew --prefix)/etc/profile.d/z.sh" ]] && . "$(brew --prefix)/etc/profile.d/z.sh"
[ -f "$HOME/.fzf.bash" ] && . "$HOME/.fzf.bash"
# if hash poetry 2>/dev/null; then
# eval "poetry completions bash > $(brew --prefix)/etc/bash_completion.d/poetry.bash-completion";
# fi
# rbenv
if hash rbenv 2>/dev/null; then
eval "$(rbenv init -)";
fi
[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" $HOME/.ssh/config | grep -v "[?*]" | cut -d " " -f2- | tr ' ' '\n')" scp sftp ssh;
[ -e "$(brew --prefix)/bin/terraform" ] && complete -C "$(brew --prefix)/bin/terraform" terraform
# Add `killall` tab completion for common apps.
complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTerm2 iTunes SystemUIServer Terminal Twitter" killall;
export DOCKER_BUILDKIT=0
export COMPOSE_DOCKER_CLI_BUILD=0
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion