-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
196 lines (158 loc) · 5.6 KB
/
.zshrc
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
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="powerlevel10k/powerlevel10k"
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git rbenv z)
# interestingPlugins=(brew bundler jira vscode xcode)
source $ZSH/oh-my-zsh.sh
##########################
### User Configuration ###
##########################
# export MANPATH="/usr/local/man:$MANPATH"
export PATH="/opt/homebrew/bin:$PATH"
# You may need to manually set your language environment
export LANG=en_US.UTF-8
# Setup Android paths
export ANDROID_HOME="$HOME/Library/Android/sdk"
export PATH="$PATH:$ANDROID_HOME/tools"
export PATH="$PATH:$ANDROID_HOME/tools/bin"
export PATH="$PATH:$ANDROID_HOME/platform-tools"
# Added by Amplify CLI binary installer
export PATH="$HOME/.amplify/bin:$PATH"
# Preferred editor for local and remote sessions
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='vim'
else
export EDITOR='code'
fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
###############
### Aliases ###
###############
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
# Run the setup.sh script of the macOS setup repository
alias setup='cd ~/.macos-setup && sh setup.sh'
# Bundler
alias ba='bundle add'
alias bck='bundle check'
alias bcn='bundle clean'
alias be='bundle exec'
alias bi='bundle install'
alias bl='bundle list'
alias bout='bundle outdated'
alias bu='bundle update'
# Bundler + X
alias bef='bundle exec fastlane'
alias bep='bundle exec pod'
# Shortcuts
alias s='code .'
alias o='open .'
alias d='cd ~/Documents'
alias dl='cd ~/Downloads'
alias dt='cd ~/Desktop'
alias x='cd ~/Developer'
# Enable aliases to be sudo’ed
alias sudo='sudo '
# Clean up LaunchServices to remove duplicates in the “Open With” menu
alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
# Get macOS Software Updates, and update installed Ruby gems, Homebrew, and their installed packages
alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; sudo gem update --system; sudo gem update; sudo gem cleanup'
# Get week number
alias week='date +%V'
# Hide/show all desktop icons (useful when presenting)
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
# IP addresses
alias ip='dig +short myip.opendns.com @resolver1.opendns.com'
alias localip='ipconfig getifaddr en0'
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
# PlistBuddy alias, because sometimes `defaults` just doesn’t cut it
alias plistbuddy="/usr/libexec/PlistBuddy"
# Show active network interfaces
alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'"
# SSH Key
alias pubkey="more ~/.ssh/id_ed25519.pub | pbcopy | echo '=> Public key copied to pasteboard.'"
########################
### Helper functions ###
########################
# Open based on z path
function o() {
z $1 && open .
}
#
function e() {
_z $1
git pull
# gittower .
code .
}
# Go to the root of the current git project, or just go one folder up
function up() {
export git_dir="$(git rev-parse --show-toplevel 2> /dev/null)"
if [ -z $git_dir ]; then
cd ..
else
cd $git_dir
fi
}
# Add the given email to the local git config
function git_email() {
git config --local --unset user.email
git config --local --add user.email "$1"
}
# Xcode via @orta
function openx() {
if test -n "$(find . -maxdepth 1 -name '*.xcworkspace' -print -quit)"; then
echo "Opening workspace"
open *.xcworkspace
return
else
if test -n "$(find . -maxdepth 1 -name '*.xcodeproj' -print -quit)"; then
echo "Opening project"
open *.xcodeproj
return
else
echo "Nothing found"
fi
fi
}
####################
### Powerlevel10k ###
####################
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
#######################
### Powerline Shell ###
#######################
# function powerline_precmd() {
# PS1="$(powerline-shell --shell zsh $?)"
# }
# function install_powerline_precmd() {
# for s in "${precmd_functions[@]}"; do
# if [ "$s" = "powerline_precmd" ]; then
# return
# fi
# done
# precmd_functions+=(powerline_precmd)
# }
# if [ "$TERM" != "linux" ]; then
# install_powerline_precmd
# fi