-
Notifications
You must be signed in to change notification settings - Fork 1
/
.profile
129 lines (106 loc) · 4.04 KB
/
.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
path_append() {
new_path=$1
if [ -d "$new_path" ] && [[ ":$PATH:" != *":$new_path:"* ]]; then
PATH="${PATH:+"$PATH:"}$new_path"
fi
}
path_prepend() {
new_path=$1
if [ -d "$new_path" ]; then
PATH=${PATH//":$new_path:"/:} #delete all instances in the middle
PATH=${PATH/%":$new_path"/} #delete any instance at the end
PATH=${PATH/#"$new_path:"/} #delete any instance at the beginning
PATH="$new_path${PATH:+":$PATH"}" #prepend $new_path or if $PATH is empty set to $new_path
fi
}
brew_dir="/usr/local" # On Intel machines Homebrew installs to /usr/local, which is already on the PATH
if [ "$(arch)" = "arm64" ]; then
# On Apple Silicon machines Homebrew installs to /opt/homebrew, which isn't on the PATH.
brew_dir="/opt/homebrew"
fi
brew_cmd="${brew_dir}/bin/brew"
if command -v "$brew_cmd" > /dev/null 2>&1; then
# Export HOMEBREW_* settings
eval "$($brew_cmd shellenv)"
fi
# On some systems, e.g., macOS 10.15, /usr/local/bin is already at the front of
# PATH by way of `/etc/paths`. On other systems it might not be there. `brew shellenv`
# will add it and `/usr/local/sbin` to the front of PATH. Meaning we might have
# dupes, making PATH searching slower. To normalize all of this, we'll prepend
# them here, and remove any dupes already there.
path_prepend /usr/local/bin
if command -v cargo > /dev/null 2>&1; then
path_prepend "$HOME/.cargo/bin"
fi
# Initialize "xenv" language managers, if they're installed
if command -v go > /dev/null 2>&1; then
path_prepend "$(go env GOPATH)/bin"
fi
nodenv_bin="${HOME}/.nodenv/bin"
if command -v nodenv > /dev/null 2>&1; then
eval "$(nodenv init -)"
elif [ -f "${nodenv_bin}/nodenv" ]; then
eval "$("${nodenv_bin}/nodenv" init - zsh)"
path_prepend "${nodenv_bin}"
fi
if command -v yarn > /dev/null 2>&1; then
yarn_bin="$(yarn global bin)"
path_append "$yarn_bin"
fi
rbenv_bin="${HOME}/.rbenv/bin"
if command -v rbenv > /dev/null 2>&1; then
eval "$(rbenv init -)"
elif [ -f "${rbenv_bin}/rbenv" ]; then
eval "$("${rbenv_bin}/rbenv" init -)"
path_prepend "${rbenv_bin}"
fi
# More PATH configuration
mkdir -p "$HOME"/bin
path_append "$HOME"/bin
# Other Customization
if [[ -e "$HOME"/.iterm2_shell_integration.zsh ]]; then
source "$HOME"/.iterm2_shell_integration.zsh
fi
# Set fzf to use ripgrep for CTRL-T in shell
export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow --glob "!{.git,node_modules}/*"'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
# Source 1Password CLI config
if [[ -e "$HOME"/.config/op/plugins.sh ]]; then
source "$HOME"/.config/op/plugins.sh
fi
# source local config
if [[ -r "$HOME"/.profile.local ]]; then
source "$HOME"/.profile.local
fi
# Editor registration for git, etc...
export CDPATH=:"$HOME"/code
export CLICOLOR=1
export EDITOR="vim"
export GEM_OPEN_EDITOR="vim"
export LC_CTYPE="en_US.UTF-8"
export PGOPTIONS='-c client_min_messages=WARNING'
export RIPGREP_CONFIG_PATH="$HOME"/.ripgreprc
THOR_MERGE="$(git config --get mergetool.Kaleidoscope.cmd)"
export THOR_MERGE
# My aliases
alias be='bundle exec'
alias gvim='mvim -p'
alias mysql_start='mysql.server start'
alias mysql_stop='mysql.server stop'
# These Postgres aliases assume we're using a shared data dir, rather than versioned data dirs
# See output of `brew info postgresql` for more.
alias pg_start='pg_ctl -D ${HOMEBREW_PREFIX}/var/postgres start'
alias pg_stop='pg_ctl -D ${HOMEBREW_PREFIX}/var/postgres stop -s -m fast'
alias redis_start='redis-server ${HOMEBREW_PREFIX}/etc/redis.conf'
alias tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale"
ghpr() {
# Shamelessly stolen from https://twitter.com/elijahmanor/status/1559525388417503233
GH_FORCE_TTY=100% gh pr list | fzf --ansi --preview 'GH_FORCE_TTY=100% gh pr view {1}' --preview-window down --header-lines 3 | awk '{print $1}' | xargs gh pr checkout
}
gitdays() {
git log --author=Steven --reverse --since="$* days ago" --pretty="format:%n%Cgreen%cd%n%n%s%n%b%n---------------------------------------------"
}
# Open a file in Marked.app. Usage: $ marked path/to/file.markdown
marked() {
open -a Marked\ 2.app "$@"
}