-
Notifications
You must be signed in to change notification settings - Fork 1
/
.zshrc
146 lines (118 loc) · 4.73 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
# Customize the PATH
export PATH=$PATH:~/bin:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/opt/coreutils/libexec/gnubin
# Include Git binaries
export PATH=$PATH:/usr/local/git/bin
# Include Composer binaries
export PATH=$PATH:~/.composer/vendor/bin
# Include WP-CLI binaries
export PATH=$PATH:~/.wp-cli/bin
# Include VS Code binaries
export PATH=$PATH:/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin
# Include PHP 7.4
export PATH=/usr/local/opt/[email protected]/bin:$PATH
export PATH=/usr/local/opt/[email protected]/sbin:$PATH
# Set default editor to VS Code
export EDITOR=code
# Load oh-my-zsh plugins
# Core plugins are found in ~/.oh-my-zsh/plugins/
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
plugins=(1password brew colorize common-aliases composer git git-extras github gitignore macos node npm sudo urltools vscode wp-cli zsh-autosuggestions zsh-syntax-highlighting zsh-dircolors-solarized)
# Path to oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load (stored in ~/.oh-my-zsh/themes/)
ZSH_THEME="agnoster"
# Set default user (removes from prompt if matches current user)
DEFAULT_USER="brian"
# Load oh-my-zsh
source $ZSH/oh-my-zsh.sh
# ZSH Syntax highlighting
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)
ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')
# Enable aliases to be sudo’ed
alias sudo='sudo '
# Misc Shortcuts
alias reload="source ~/.zshrc"
alias o="open"
alias oo="open ."
alias makemkv="/Applications/MakeMKV.app/Contents/MacOS/makemkvcon"
alias code="code -n"
alias yt="youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4'"
# Git shortcuts
alias pr="gh pr create"
alias dev="cd ~/Sites/www"
# Networking shortcuts
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en1"
alias ips="ifconfig -a | grep -o 'inet6\? \(\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\|[a-fA-F0-9:]\+\)' | sed -e 's/inet6* //'"
alias whois="whois -h whois-servers.net"
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
alias flush="dscacheutil -flushcache"
# Edit local hosts file
alias hosts="sudo ${=EDITOR} /etc/hosts"
# OS X has no `md5sum`, so use `md5` as a fallback
command -v md5sum > /dev/null || alias md5sum="md5"
# Cleanup shortcuts
# Recursively delete `.DS_Store` files
alias dscleanup="find . -type f -name '*.DS_Store' -ls -delete"
# 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"
# Empty the Trash on all mounted volumes and clear system logs to improve shell startup speed
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl"
# Show/hide desktop files (useful for 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"
# Install a new WP site
function wpinstall() {
mkdir -p ~/Sites/www/$@ && cd $_;
wp core download;
wp core config --dbname=$@;
wp config set WP_DEBUG true --raw;
wp db create;
wp core install --url=https://[email protected] --title=$( tr '[A-Z]' '[a-z]' <<< $@ );
wp login install --activate;
valet secure $@;
wp login as brian --launch;
}
# Individually update and commit plugins on a WP site
function pluginupdate() {
for plugin in $(wp plugin list --update=available --fields=name,version,update_version --format=csv);
do
IFS="," read -r name old new <<< "$plugin"
if [ $name = "name" ]; then
continue
fi
wp plugin update $name &&
git add -A ./wp-content/plugins/$name &&
git commit -m "Update plugin $name from $old to $new"
done;
}
# Import the production database from Pantheon
function dbsync() {
SITE=${PWD##*/};
terminus backup:create --element=db $SITE.live;
terminus backup:get --element=db --to=$SITE.sql.gz $SITE.live;
gunzip $SITE.sql.gz;
wp db import $SITE.sql;
rm $SITE.sql;
}
# Import the production uploads from Pantheon
# Requires the terminus rsync plugin (https://github.com/pantheon-systems/terminus-rsync-plugin)
function filesync() {
SITE=${PWD##*/};
terminus rsync $SITE.live:files/ ./wp-content/uploads
}
# Deploy to pantheon
# Usage: deploy both OR deploy test OR deploy live
function deploy() {
SITE=${PWD##*/};
if [[ $1 == "both" ]]; then
terminus env:deploy $SITE.test && terminus env:deploy $SITE.live;
else
terminus env:deploy $SITE.$1;
fi
}
function webm2mp4() {
echo "\nConverting $@ to ${@%.*}.mp4\n"
ffmpeg -i $@ -c:v copy ${@%.*}.mp4
}