From zero to fully installed and configured, in an hour.
case "${SHELL}" in
(*zsh) ;;
(*) chsh -s "$(which zsh)"; exit 1 ;;
esaccurl --location --silent \ "https://github.com/ptb/mac-setup/raw/develop/mac-setup.command" | \ source /dev/stdin 0
init && install && config
custom && personalize_all
- Enter administrator account password only once
- Select the cache folder for repeat installations
- Turn off sleep and set computer name/hostname
- Set write permission on destination folders
- Cache software updates and App Store software
- Install developer tools and macOS updates
- Homebrew: The missing package mananger for macOS
- Homebrew-Cask: “To install, drag this icon…” no more!
- mas-cli/mas: Mac App Store command line interface
- homebrew-bundle: List all Homebrew packages in
Brewfile - Node.js: Cross-platform JavaScript run-time environment
- Perl 5: Highly capable, feature-rich programming language
- Python: Programming language that lets you work quickly
- Ruby: Language with a focus on simplicity and productivity
- Configure software requiring an administrator account
- Optionally configure local Dovecot secure IMAP server
- Create your primary non-administrator account
- Remove password-less administrator account permission
- Recommended that you log out of administrator account
- Log in with your new non-administrator account
- Create or clone a git repository into your home folder
- Install Atom packages and customize preferences
- Set the desktop picture to a solid black color
- Customize the dock with new default applications
- Customize Emacs with Spacemacs: Emacs plus Vim!
- Set all preferences automatically and consistently
- macOS High Sierra: Tested with macOS High Sierra 10.13 (17A365).
- Completely Automated: Homebrew, Cask, and
mas-cliinstall everything. - Latest Versions: Includes Node, Perl, Python, and Ruby separate from macOS.
- Customized Terminal: Colors and fonts decyphered into editable preferences.
- Idempotent: This script is intended to be safe to run more than once.
macappstores://itunes.apple.com/app/id1209167288
diskx="$(diskutil list internal physical | sed '/^\//!d;s/^\(.*\)\ (.*):/\1/')"
diskutil zeroDisk $diskx diskutil partitionDisk $diskx 2 GPT \ jhfs+ "Install" 6G \ apfs $(ruby -e "print '$(hostname -s)'.capitalize") R
sudo "/Applications/Install macOS High Sierra.app/Contents/Resources/createinstallmedia" \ --applicationpath "/Applications/Install macOS High Sierra.app" --nointeraction \ --volume "/Volumes/Install"
Copyright 2017 Peter T Bosse II
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
if test -z "${1}"; then
osascript - "${0}" << EOF > /dev/null 2>&1
<<new_term.applescript>>
EOF
fion run { _this }
tell app "Terminal" to do script "source " & quoted form of _this & " 0"
end runask () {
osascript - "${1}" "${2}" "${3}" << EOF 2> /dev/null
<<ask.applescript>>
EOF
}on run { _title, _action, _default }
tell app "System Events" to return text returned of (display dialog _title with title _title buttons { "Cancel", _action } default answer _default)
end runask2 () {
osascript - "$1" "$2" "$3" "$4" "$5" "$6" << EOF 2> /dev/null
<<ask2.applescript>>
EOF
}on run { _text, _title, _cancel, _action, _default, _hidden }
tell app "Terminal" to return text returned of (display dialog _text with title _title buttons { _cancel, _action } cancel button _cancel default button _action default answer _default hidden answer _hidden)
end runp () {
printf "\n\033[1m\033[34m%s\033[0m\n\n" "${1}"
}run () {
osascript - "${1}" "${2}" "${3}" << EOF 2> /dev/null
<<run.applescript>>
EOF
}on run { _title, _cancel, _action }
tell app "Terminal" to return button returned of (display dialog _title with title _title buttons { _cancel, _action } cancel button 1 default button 2 giving up after 5)
end runinit () {
init_sudo
init_cache
init_no_sleep
init_hostname
init_perms
init_maskeep
init_updates
config_new_account
config_rm_sudoers
}
if test "${1}" = 0; then
printf "\n$(which init)\n"
fiinit_paths () {
test -x "/usr/libexec/path_helper" && \
eval $(/usr/libexec/path_helper -s)
}init_sudo () {
printf "%s\n" "%wheel ALL=(ALL) NOPASSWD: ALL" | \
sudo tee "/etc/sudoers.d/wheel" > /dev/null && \
sudo dscl /Local/Default append /Groups/wheel GroupMembership "$(whoami)"
}init_cache () {
grep -q "CACHES" "/etc/zshenv" 2> /dev/null || \
a=$(osascript << EOF 2> /dev/null
<<init_cache.applescript>>
EOF
) && \
test -d "${a}" || \
a="${HOME}/Library/Caches/"
grep -q "CACHES" "/etc/zshenv" 2> /dev/null || \
printf "%s\n" \
"export CACHES=\"${a}\"" \
"export HOMEBREW_CACHE=\"${a}/brew\"" \
"export BREWFILE=\"${a}/brew/Brewfile\"" | \
sudo tee -a "/etc/zshenv" > /dev/null
. "/etc/zshenv"
if test -d "${CACHES}/upd"; then
sudo chown -R "$(whoami)" "/Library/Updates"
rsync -a --delay-updates \
"${CACHES}/upd/" "/Library/Updates/"
fi
}on run
return text 1 through -2 of POSIX path of (choose folder with prompt "Select Installation Cache Location")
end runinit_no_sleep () {
sudo pmset -a sleep 0
sudo pmset -a disksleep 0
}init_hostname () {
a=$(ask2 "Set Computer Name and Hostname" "Set Hostname" "Cancel" "Set Hostname" $(ruby -e "print '$(hostname -s)'.capitalize") "false")
if test -n $a; then
sudo scutil --set ComputerName $(ruby -e "print '$a'.capitalize")
sudo scutil --set HostName $(ruby -e "print '$a'.downcase")
fi
}init_perms () {
printf "%s\n" "${_dest}" | \
while IFS="$(printf '\t')" read d; do
test -d "${d}" || sudo mkdir -p "${d}"
sudo chgrp -R admin "${d}"
sudo chmod -R g+w "${d}"
done
}| Location | Install Path |
|---|---|
| /usr/local/bin | |
| /Library/Desktop Pictures | |
| colorpickerdir | /Library/ColorPickers |
| fontdir | /Library/Fonts |
| input_methoddir | /Library/Input Methods |
| prefpanedir | /Library/PreferencePanes |
| qlplugindir | /Library/QuickLook |
| screen_saverdir | /Library/Screen Savers |
| /Library/User Pictures |
init_devtools () {
p="${HOMEBREW_CACHE}/Cask/Command Line Tools (macOS High Sierra version 10.13).pkg"
i="com.apple.pkg.CLTools_SDK_macOS1013"
if test -f "${p}"; then
if ! pkgutil --pkg-info "${i}" > /dev/null 2>&1; then
sudo installer -pkg "${p}" -target /
fi
else
xcode-select --install
fi
}init_xcode () {
if test -f ${HOMEBREW_CACHE}/Cask/xcode*.xip; then
p "Installing Xcode"
dest="${HOMEBREW_CACHE}/Cask/xcode"
if ! test -d "$dest"; then
pkgutil --expand ${HOMEBREW_CACHE}/Cask/xcode*.xip "$dest"
curl --location --silent \
"https://gist.githubusercontent.com/pudquick/ff412bcb29c9c1fa4b8d/raw/24b25538ea8df8d0634a2a6189aa581ccc6a5b4b/parse_pbzx2.py" | \
python - "${dest}/Content"
find "${dest}" -empty -name "*.xz" -type f -print0 | \
xargs -0 -l 1 rm
find "${dest}" -name "*.xz" -print0 | \
xargs -0 -L 1 gunzip
cat ${dest}/Content.part* > \
${dest}/Content.cpio
fi
cd /Applications && \
sudo cpio -dimu --file=${dest}/Content.cpio
for pkg in /Applications/Xcode*.app/Contents/Resources/Packages/*.pkg; do
sudo installer -pkg "$pkg" -target /
done
x="$(find '/Applications' -maxdepth 1 -regex '.*/Xcode[^ ]*.app' -print -quit)"
if test -n "${x}"; then
sudo xcode-select -s "${x}"
sudo xcodebuild -license accept
fi
fi
}init_updates () {
sudo softwareupdate --install --all
}sudo lsof -c softwareupdated -F -r 2 | sed '/^n\//!d;/com.apple.SoftwareUpdate/!d;s/^n//' sudo lsof -c storedownloadd -F -r 2 | sed '/^n\//!d;/com.apple.appstore/!d;s/^n//'
init_maskeep () {
sudo softwareupdate --reset-ignored > /dev/null
cat << EOF > "/usr/local/bin/maskeep"
<<maskeep.sh>>
EOF
chmod a+x "/usr/local/bin/maskeep"
rehash
config_launchd "/Library/LaunchDaemons/com.github.ptb.maskeep.plist" "$_maskeep_launchd" "sudo" ""
}| Command | Entry | Type | Value |
|---|---|---|---|
| add | :KeepAlive | bool | false |
| add | :Label | string | com.github.ptb.maskeep |
| add | :ProcessType | string | Background |
| add | :Program | string | /usr/local/bin/maskeep |
| add | :RunAtLoad | bool | true |
| add | :StandardErrorPath | string | /dev/stderr |
| add | :StandardOutPath | string | /dev/stdout |
| add | :UserName | string | root |
| add | :WatchPaths | array | |
| add | :WatchPaths:0 | string | $(sudo find ‘/private/var/folders’ -name ‘com.apple.SoftwareUpdate’ -type d -user _softwareupdate -print -quit 2> /dev/null) |
| add | :WatchPaths:1 | string | $(sudo -u \#501 – sh -c ‘getconf DARWIN_USER_CACHE_DIR’ 2> /dev/null)com.apple.appstore |
| add | :WatchPaths:2 | string | $(sudo -u \#502 – sh -c ‘getconf DARWIN_USER_CACHE_DIR’ 2> /dev/null)com.apple.appstore |
| add | :WatchPaths:3 | string | $(sudo -u \#503 – sh -c ‘getconf DARWIN_USER_CACHE_DIR’ 2> /dev/null)com.apple.appstore |
| add | :WatchPaths:4 | string | /Library/Updates |
#!/bin/sh
asdir="/Library/Caches/storedownloadd"
as1="\$(sudo -u \\#501 -- sh -c 'getconf DARWIN_USER_CACHE_DIR' 2> /dev/null)com.apple.appstore"
as2="\$(sudo -u \\#502 -- sh -c 'getconf DARWIN_USER_CACHE_DIR' 2> /dev/null)com.apple.appstore"
as3="\$(sudo -u \\#503 -- sh -c 'getconf DARWIN_USER_CACHE_DIR' 2> /dev/null)com.apple.appstore"
upd="/Library/Updates"
sudir="/Library/Caches/softwareupdated"
su="\$(sudo find '/private/var/folders' -name 'com.apple.SoftwareUpdate' -type d -user _softwareupdate 2> /dev/null)"
for i in 1 2 3 4 5; do
mkdir -m a=rwxt -p "\$asdir"
for as in "\$as1" "\$as2" "\$as3" "\$upd"; do
test -d "\$as" && \
find "\${as}" -type d -print | \\
while read a; do
b="\${asdir}/\$(basename \$a)"
mkdir -p "\${b}"
find "\${a}" -type f -print | \\
while read c; do
d="\$(basename \$c)"
test -e "\${b}/\${d}" || \\
ln "\${c}" "\${b}/\${d}" && \\
chmod 666 "\${b}/\${d}"
done
done
done
mkdir -m a=rwxt -p "\${sudir}"
find "\${su}" -name "*.tmp" -type f -print | \\
while read a; do
d="\$(basename \$a)"
test -e "\${sudir}/\${d}.xar" ||
ln "\${a}" "\${sudir}/\${d}.xar" && \\
chmod 666 "\${sudir}/\${d}.xar"
done
sleep 1
done
exit 0install () {
install_macos_sw
install_node_sw
install_perl_sw
install_python_sw
install_ruby_sw
which config
}install_macos_sw () {
p "Installing macOS Software"
install_paths
install_brew
install_brewfile_taps
install_brewfile_brew_pkgs
install_brewfile_cask_args
install_brewfile_cask_pkgs
install_brewfile_mas_apps
x=$(find '/Applications' -maxdepth 1 -regex '.*/Xcode[^ ]*.app' -print -quit)
if test -n "$x"; then
sudo xcode-select -s "$x"
sudo xcodebuild -license accept
fi
brew bundle --file="${BREWFILE}"
x=$(find '/Applications' -maxdepth 1 -regex '.*/Xcode[^ ]*.app' -print -quit)
if test -n "$x"; then
sudo xcode-select -s "$x"
sudo xcodebuild -license accept
fi
install_links
sudo xattr -rd "com.apple.quarantine" "/Applications" > /dev/null 2>&1
sudo chmod -R go=u-w "/Applications" > /dev/null 2>&1
}install_paths () {
if ! grep -Fq "/usr/local/sbin" /etc/paths; then
sudo sed -i "" -e "/\/usr\/sbin/{x;s/$/\/usr\/local\/sbin/;G;}" /etc/paths
fi
}install_brew () {
if ! which brew > /dev/null; then
ruby -e \
"$(curl -Ls 'https://github.com/Homebrew/install/raw/master/install')" \
< /dev/null > /dev/null 2>&1
fi
printf "" > "${BREWFILE}"
brew analytics off
brew update
brew doctor
brew tap "homebrew/bundle"
}install_brewfile_taps () {
printf "%s\n" "${_taps}" | \
while IFS="$(printf '\t')" read tap; do
printf 'tap "%s"\n' "${tap}" >> "${BREWFILE}"
done
printf "\n" >> "${BREWFILE}"
}| Homebrew Tap Name | Reference URL |
|---|---|
| caskroom/cask | https://github.com/caskroom/homebrew-cask |
| caskroom/fonts | https://github.com/caskroom/homebrew-fonts |
| caskroom/versions | https://github.com/caskroom/homebrew-versions |
| homebrew/bundle | https://github.com/Homebrew/homebrew-bundle |
| homebrew/command-not-found | https://github.com/Homebrew/homebrew-command-not-found |
| homebrew/nginx | https://github.com/Homebrew/homebrew-nginx |
| homebrew/php | https://github.com/Homebrew/homebrew-php |
| homebrew/services | https://github.com/Homebrew/homebrew-services |
| ptb/custom | https://github.com/ptb/homebrew-custom |
| railwaycat/emacsmacport | https://github.com/railwaycat/homebrew-emacsmacport |
install_brewfile_brew_pkgs () {
printf "%s\n" "${_pkgs}" | \
while IFS="$(printf '\t')" read pkg; do
# printf 'brew "%s", args: [ "force-bottle" ]\n' "${pkg}" >> "${BREWFILE}"
printf 'brew "%s"\n' "${pkg}" >> "${BREWFILE}"
done
printf "\n" >> "${BREWFILE}"
}install_brewfile_cask_args () {
printf 'cask_args \' >> "${BREWFILE}"
printf "%s\n" "${_args}" | \
while IFS="$(printf '\t')" read arg dir; do
printf '\n %s: "%s",' "${arg}" "${dir}" >> "${BREWFILE}"
done
sed -i "" -e '$ s/,/\
/' "${BREWFILE}"
}install_brewfile_cask_pkgs () {
printf "%s\n" "${_casks}" | \
while IFS="$(printf '\t')" read cask; do
printf 'cask "%s"\n' "${cask}" >> "${BREWFILE}"
done
printf "\n" >> "${BREWFILE}"
}install_brewfile_mas_apps () {
open "/Applications/App Store.app"
run "Sign in to the App Store with your Apple ID" "Cancel" "OK"
MASDIR="$(getconf DARWIN_USER_CACHE_DIR)com.apple.appstore"
sudo chown -R "$(whoami)" "${MASDIR}"
rsync -a --delay-updates \
"${CACHES}/mas/" "${MASDIR}/"
printf "%s\n" "${_mas}" | \
while IFS="$(printf '\t')" read app id; do
printf 'mas "%s", id: %s\n' "${app}" "${id}" >> "${BREWFILE}"
done
}install_links () {
printf "%s\n" "${_links}" | \
while IFS="$(printf '\t')" read link; do
find "${link}" -maxdepth 1 -name "*.app" -type d -print0 2> /dev/null | \
xargs -0 -I {} -L 1 ln -s "{}" "/Applications" 2> /dev/null
done
}| Application Locations |
|---|
| /System/Library/CoreServices/Applications |
| /Applications/Xcode.app/Contents/Applications |
| /Applications/Xcode.app/Contents/Developer/Applications |
| /Applications/Xcode-beta.app/Contents/Applications |
| /Applications/Xcode-beta.app/Contents/Developer/Applications |
install_node_sw () {
if which nodenv > /dev/null; then
NODENV_ROOT="/usr/local/node" && export NODENV_ROOT
sudo mkdir -p "$NODENV_ROOT"
sudo chown -R "$(whoami):admin" "$NODENV_ROOT"
p "Installing Node.js with nodenv"
git clone https://github.com/nodenv/node-build-update-defs.git \
"$(nodenv root)"/plugins/node-build-update-defs
nodenv update-version-defs > /dev/null
nodenv install --skip-existing 8.7.0
nodenv global 8.7.0
grep -q "${NODENV_ROOT}" "/etc/paths" || \
sudo sed -i "" -e "1i\\
${NODENV_ROOT}/shims
" "/etc/paths"
init_paths
rehash
fi
T=$(printf '\t')
printf "%s\n" "$_npm" | \
while IFS="$T" read pkg; do
npm install --global "$pkg"
done
rehash
}| NPM Package Name | Reference URL |
|---|---|
| eslint | https://eslint.org/ |
| eslint-config-cleanjs | https://github.com/bodil/eslint-config-cleanjs |
| eslint-plugin-better | https://github.com/idmitriev/eslint-plugin-better |
| eslint-plugin-fp | https://github.com/jfmengels/eslint-plugin-fp |
| eslint-plugin-import | https://github.com/benmosher/eslint-plugin-import |
| eslint-plugin-json | https://github.com/azeemba/eslint-plugin-json |
| eslint-plugin-promise | https://github.com/xjamundx/eslint-plugin-promise |
| eslint-plugin-standard | https://github.com/xjamundx/eslint-plugin-standard |
| gatsby | |
| json | http://trentm.com/json/ |
| sort-json | https://github.com/kesla/sort-json |
install_perl_sw () {
if which plenv > /dev/null; then
PLENV_ROOT="/usr/local/perl" && export PLENV_ROOT
sudo mkdir -p "$PLENV_ROOT"
sudo chown -R "$(whoami):admin" "$PLENV_ROOT"
p "Installing Perl 5 with plenv"
plenv install 5.26.0 > /dev/null 2>&1
plenv global 5.26.0
grep -q "${PLENV_ROOT}" "/etc/paths" || \
sudo sed -i "" -e "1i\\
${PLENV_ROOT}/shims
" "/etc/paths"
init_paths
rehash
fi
}install_python_sw () {
if which pyenv > /dev/null; then
CFLAGS="-I$(brew --prefix openssl)/include" && export CFLAGS
LDFLAGS="-L$(brew --prefix openssl)/lib" && export LDFLAGS
PYENV_ROOT="/usr/local/python" && export PYENV_ROOT
sudo mkdir -p "$PYENV_ROOT"
sudo chown -R "$(whoami):admin" "$PYENV_ROOT"
p "Installing Python 2 with pyenv"
pyenv install --skip-existing 2.7.13
p "Installing Python 3 with pyenv"
pyenv install --skip-existing 3.6.2
pyenv global 2.7.13
grep -q "${PYENV_ROOT}" "/etc/paths" || \
sudo sed -i "" -e "1i\\
${PYENV_ROOT}/shims
" "/etc/paths"
init_paths
rehash
pip install --upgrade "pip" "setuptools"
# Reference: https://github.com/mdhiggins/sickbeard_mp4_automator
pip install --upgrade "babelfish" "guessit<2" "qtfaststart" "requests" "stevedore==1.19.1" "subliminal<2"
pip install --upgrade "requests-cache" "requests[security]"
# Reference: https://github.com/pixelb/crudini
pip install --upgrade "crudini"
fi
}install_ruby_sw () {
if which rbenv > /dev/null; then
RBENV_ROOT="/usr/local/ruby" && export RBENV_ROOT
sudo mkdir -p "$RBENV_ROOT"
sudo chown -R "$(whoami):admin" "$RBENV_ROOT"
p "Installing Ruby with rbenv"
rbenv install --skip-existing 2.4.2
rbenv global 2.4.2
grep -q "${RBENV_ROOT}" "/etc/paths" || \
sudo sed -i "" -e "1i\\
${RBENV_ROOT}/shims
" "/etc/paths"
init_paths
rehash
printf "%s\n" \
"gem: --no-document" | \
tee "${HOME}/.gemrc" > /dev/null
gem update --system > /dev/null
trash "$(which rdoc)"
trash "$(which ri)"
gem update
gem install bundler
fi
}config () {
config_admin_req
config_bbedit
config_certbot
config_desktop
config_dovecot
config_emacs
config_environment
config_ipmenulet
config_istatmenus
config_nginx
config_openssl
config_sysprefs
config_zsh
config_guest
which custom
}config_defaults () {
printf "%s\n" "${1}" | \
while IFS="$(printf '\t')" read domain key type value host; do
${2} defaults ${host} write ${domain} "${key}" ${type} "${value}"
done
}T="$(printf '\t')"
config_plist () {
printf "%s\n" "$1" | \
while IFS="$T" read command entry type value; do
case "$value" in
(\$*)
$4 /usr/libexec/PlistBuddy "$2" \
-c "$command '${3}${entry}' $type '$(eval echo \"$value\")'" 2> /dev/null ;;
(*)
$4 /usr/libexec/PlistBuddy "$2" \
-c "$command '${3}${entry}' $type '$value'" 2> /dev/null ;;
esac
done
}config_launchd () {
test -d "$(dirname $1)" || \
$3 mkdir -p "$(dirname $1)"
test -f "$1" && \
$3 launchctl unload "$1" && \
$3 rm -f "$1"
config_plist "$2" "$1" "$4" "$3" && \
$3 plutil -convert xml1 "$1" && \
$3 launchctl load "$1"
}config_admin_req () {
printf "%s\n" "${_admin_req}" | \
while IFS="$(printf '\t')" read app; do
sudo tag -a "Red, admin" "/Applications/${app}"
done
}| Admin Apps |
|---|
| Carbon Copy Cloner.app |
| Charles.app |
| Composer.app |
| Dropbox.app |
| iStat Menus.app |
| Moom.app |
| VMware Fusion.app |
| Wireshark.app |
config_bbedit () {
if test -d "/Applications/BBEdit.app"; then
test -f "/usr/local/bin/bbdiff" || \
ln /Applications/BBEdit.app/Contents/Helpers/bbdiff /usr/local/bin/bbdiff && \
ln /Applications/BBEdit.app/Contents/Helpers/bbedit_tool /usr/local/bin/bbedit && \
ln /Applications/BBEdit.app/Contents/Helpers/bbfind /usr/local/bin/bbfind && \
ln /Applications/BBEdit.app/Contents/Helpers/bbresults /usr/local/bin/bbresults
fi
}config_certbot () {
test -d "/etc/letsencrypt" || \
sudo mkdir -p /etc/letsencrypt
sudo tee "/etc/letsencrypt/cli.ini" << EOF > /dev/null
agree-tos = True
authenticator = standalone
eff-email = True
manual-public-ip-logging-ok = True
nginx-ctl = $(which nginx)
nginx-server-root = /usr/local/etc/nginx
preferred-challenges = tls-sni-01
keep-until-expiring = True
rsa-key-size = 4096
text = True
EOF
if ! test -e "/etc/letsencrypt/.git"; then
a=$(ask "Existing Let’s Encrypt Git Repository Path or URL?" "Clone Repository" "")
test -n "$a" && \
case "$a" in
(/*)
sudo tee "/etc/letsencrypt/.git" << EOF > /dev/null ;;
gitdir: $a
EOF
(*)
sudo git -C "/etc/letsencrypt" remote add origin "$a"
sudo git -C "/etc/letsencrypt" fetch origin master ;;
esac
sudo git -C "/etc/letsencrypt" reset --hard
sudo git checkout -f -b master HEAD
fi
sudo launchctl unload /Library/LaunchDaemons/org.nginx.nginx.plist 2> /dev/null
sudo certbot renew
while true; do
test -n "$1" && server_name="$1" || \
server_name="$(ask 'New SSL Server: Server Name?' 'Create Server' 'example.com')"
test -n "$server_name" || break
test -n "$2" && proxy_address="$2" || \
proxy_address="$(ask "Proxy Address for $server_name?" 'Set Address' 'http://127.0.0.1:80')"
sudo certbot certonly --domain $server_name
key1="$(openssl x509 -pubkey < /etc/letsencrypt/live/$server_name/fullchain.pem | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64)"
key2="$(curl -s https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem | openssl x509 -pubkey | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64)"
key3="$(curl -s https://letsencrypt.org/certs/isrgrootx1.pem | openssl x509 -pubkey | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64)"
pkp="$(printf "add_header Public-Key-Pins 'pin-sha256=\"%s\"; pin-sha256=\"%s\"; pin-sha256=\"%s\"; max-age=2592000;';\n" $key1 $key2 $key3)"
cat << EOF > "/usr/local/etc/nginx/servers/$server_name.conf"
<<server_name.conf>>
EOF
unset argv
done
sudo launchctl load /Library/LaunchDaemons/org.nginx.nginx.plist
}server {
server_name $server_name;
location / {
proxy_pass $proxy_address;
}
ssl_certificate /etc/letsencrypt/live/$server_name/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/$server_name/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/$server_name/chain.pem;
$pkp
add_header Content-Security-Policy "upgrade-insecure-requests;";
add_header Referrer-Policy "strict-origin";
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains; preload" always;
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options DENY;
add_header X-Robots-Tag none;
add_header X-XSS-Protection "1; mode=block";
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_stapling on;
ssl_stapling_verify on;
# https://securityheaders.io/?q=https%3A%2F%2F$server_name&hide=on&followRedirects=on
# https://www.ssllabs.com/ssltest/analyze.html?d=$server_name&hideResults=on&latest
}
config_default_apps () {
true
}config_desktop () {
sudo rm -f "/Library/Caches/com.apple.desktop.admin.png"
base64 -D << EOF > "/Library/Desktop Pictures/Solid Colors/Solid Black.png"
<<black.png.b64>>
EOF
}iVBORw0KGgoAAAANSUhEUgAAAIAAAACAAQAAAADrRVxmAAAAGElEQVR4AWOgMxgFo2AUjIJRMApGwSgAAAiAAAH3bJXBAAAAAElFTkSuQmCC
config_dovecot () {
if which /usr/local/sbin/dovecot > /dev/null; then
if ! run "Configure Dovecot Email Server?" "Configure Server" "Cancel"; then
sudo tee "/usr/local/etc/dovecot/dovecot.conf" << EOF > /dev/null
<<dovecot.conf>>
EOF
MAILADM="$(ask 'Email: Postmaster Email?' 'Set Email' "$(whoami)@$(hostname -f | cut -d. -f2-)")"
MAILSVR="$(ask 'Email: Server Hostname for DNS?' 'Set Hostname' "$(hostname -f)")"
sudo certbot certonly --domain $MAILSVR
printf "%s\n" \
"postmaster_address = '${MAILADM}'" \
"ssl_cert = </etc/letsencrypt/live/$MAILSVR/fullchain.pem" \
"ssl_key = </etc/letsencrypt/live/$MAILSVR/privkey.pem" | \
sudo tee -a "/usr/local/etc/dovecot/dovecot.conf" > /dev/null
if test ! -f "/usr/local/etc/dovecot/cram-md5.pwd"; then
while true; do
MAILUSR="$(ask 'New Email Account: User Name?' 'Create Account' "$(whoami)")"
test -n "${MAILUSR}" || break
doveadm pw | \
sed -e "s/^/${MAILUSR}:/" | \
sudo tee -a "/usr/local/etc/dovecot/cram-md5.pwd"
done
sudo chown _dovecot "/usr/local/etc/dovecot/cram-md5.pwd"
sudo chmod go= "/usr/local/etc/dovecot/cram-md5.pwd"
fi
sudo tee "/etc/pam.d/dovecot" << EOF > /dev/null
<<dovecot.pam>>
EOF
sudo brew services start dovecot
cat << EOF > "/usr/local/bin/imaptimefix.py"
<<imaptimefix.py>>
EOF
chmod +x /usr/local/bin/imaptimefix.py
fi
fi
}auth_mechanisms = cram-md5
default_internal_user = _dovecot
default_login_user = _dovenull
log_path = /dev/stderr
mail_location = maildir:~/.mail:INBOX=~/.mail/Inbox:LAYOUT=fs
mail_plugins = zlib
maildir_copy_with_hardlinks = no
namespace {
inbox = yes
mailbox Drafts {
auto = subscribe
special_use = \Drafts
}
mailbox Junk {
auto = subscribe
special_use = \Junk
}
mailbox Sent {
auto = subscribe
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
mailbox Trash {
auto = subscribe
special_use = \Trash
}
separator = .
type = private
}
passdb {
args = scheme=cram-md5 /usr/local/etc/dovecot/cram-md5.pwd
driver = passwd-file
# driver = pam
# args = nopassword=y
# driver = static
}
plugin {
sieve = file:/Users/%u/.sieve
sieve_plugins = sieve_extprograms
zlib_save = bz2
zlib_save_level = 9
}
protocols = imap
service imap-login {
inet_listener imap {
port = 0
}
}
ssl = required
ssl_cipher_list = ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS:!AES128
ssl_dh_parameters_length = 4096
ssl_prefer_server_ciphers = yes
ssl_protocols = !SSLv2 !SSLv3
userdb {
driver = passwd
}
protocol lda {
mail_plugins = sieve zlib
}
# auth_debug = yes
# auth_debug_passwords = yes
# auth_verbose = yes
# auth_verbose_passwords = plain
# mail_debug = yes
# verbose_ssl = yes
auth required pam_opendirectory.so try_first_pass
account required pam_nologin.so
account required pam_opendirectory.so
password required pam_opendirectory.so
#!/usr/bin/env python
# Author: Zachary Cutlip <@zcutlip>
# http://shadow-file.blogspot.com/2012/06/parsing-email-and-fixing-timestamps-in.html
# Updated: Peter T Bosse II <@ptb>
# Purpose: A program to fix sorting of mail messages that have been POPed or
# IMAPed in the wrong order. Compares time stamp sent and timestamp
# received on an RFC822-formatted email message, and renames the
# message file using the most recent timestamp that is no more than
# 24 hours after the date sent. Updates the file's atime/mtime with
# the timestamp, as well. Does not modify the headers or contents of
# the message.
from bz2 import BZ2File
from email import message_from_string
from email.utils import mktime_tz, parsedate_tz
from os import rename, utime, walk
from os.path import abspath, isdir, isfile, join
from re import compile, match
from sys import argv
if isdir(argv[1]):
e = compile("([0-9]+)(\..*$)")
for a, b, c in walk(argv[1]):
for d in c:
if e.match(d):
f = message_from_string(BZ2File(join(a, d)).read())
g = mktime_tz(parsedate_tz(f.get("Date")))
h = 0
for i in f.get_all("Received", []):
j = i.split(";")[-1]
if parsedate_tz(j):
k = mktime_tz(parsedate_tz(j))
if (k - g) > (60*60*24):
continue
h = k
break
if (h < 1):
h = g
l = e.match(d)
if len(l.groups()) == 2:
m = str(int(h)) + l.groups()[1]
if not isfile(join(a, m)):
rename(join(a, d), join(a, m))
utime(join(a, m), (h, h))config_emacs () {
test -f "/usr/local/bin/vi" || \
cat << EOF > "/usr/local/bin/vi"
<<vi.sh>>
EOF
chmod a+x /usr/local/bin/vi
rehash
}#!/bin/sh
if [ -e "/Applications/Emacs.app" ]; then
t=()
if [ \${#@} -ne 0 ]; then
while IFS= read -r file; do
[ ! -f "\$file" ] && t+=("\$file") && /usr/bin/touch "\$file"
file=\$(echo \$(cd \$(dirname "\$file") && pwd -P)/\$(basename "\$file"))
\$(/usr/bin/osascript <<-END
if application "Emacs.app" is running then
tell application id (id of application "Emacs.app") to open POSIX file "\$file"
else
tell application ((path to applications folder as text) & "Emacs.app")
activate
open POSIX file "\$file"
end tell
end if
END
) & # Note: END on the previous line may be indented with tabs but not spaces
done <<<"\$(printf '%s\n' "\$@")"
fi
if [ ! -z "\$t" ]; then
\$(/bin/sleep 10; for file in "\${t[@]}"; do
[ ! -s "\$file" ] && /bin/rm "\$file";
done) &
fi
else
vim -No "\$@"
ficonfig_environment () {
sudo tee "/etc/environment.sh" << 'EOF' > /dev/null
<<environment.sh>>
EOF
sudo chmod a+x "/etc/environment.sh"
rehash
la="/Library/LaunchAgents/environment.user"
ld="/Library/LaunchDaemons/environment"
sudo mkdir -p "$(dirname $la)" "$(dirname $ld)"
sudo launchctl unload "${la}.plist" "${ld}.plist" 2> /dev/null
sudo rm -f "${la}.plist" "${ld}.plist"
config_defaults "$_environment_defaults" "sudo"
sudo plutil -convert xml1 "${la}.plist" "${ld}.plist"
sudo launchctl load "${la}.plist" "${ld}.plist" 2> /dev/null
}#!/bin/sh
set -e
if test -x /usr/libexec/path_helper; then
export PATH=""
eval `/usr/libexec/path_helper -s`
launchctl setenv PATH $PATH
fi
osascript -e 'tell app "Dock" to quit'| Domain | Key | Type | Value | Host |
|---|---|---|---|---|
| /Library/LaunchAgents/environment.user | KeepAlive | -bool | false | |
| /Library/LaunchAgents/environment.user | Label | -string | environment.user | |
| /Library/LaunchAgents/environment.user | ProcessType | -string | Background | |
| /Library/LaunchAgents/environment.user | Program | -string | /etc/environment.sh | |
| /Library/LaunchAgents/environment.user | RunAtLoad | -bool | true | |
| /Library/LaunchAgents/environment.user | WatchPaths | -array-add | /etc/environment.sh | |
| /Library/LaunchAgents/environment.user | WatchPaths | -array-add | /etc/paths | |
| /Library/LaunchAgents/environment.user | WatchPaths | -array-add | /etc/paths.d | |
| /Library/LaunchDaemons/environment | KeepAlive | -bool | false | |
| /Library/LaunchDaemons/environment | Label | -string | environment | |
| /Library/LaunchDaemons/environment | ProcessType | -string | Background | |
| /Library/LaunchDaemons/environment | Program | -string | /etc/environment.sh | |
| /Library/LaunchDaemons/environment | RunAtLoad | -bool | true | |
| /Library/LaunchDaemons/environment | WatchPaths | -array-add | /etc/environment.sh | |
| /Library/LaunchDaemons/environment | WatchPaths | -array-add | /etc/paths | |
| /Library/LaunchDaemons/environment | WatchPaths | -array-add | /etc/paths.d |
config_ipmenulet () {
_ipm="/Applications/IPMenulet.app/Contents/Resources"
if test -d "$_ipm"; then
rm "${_ipm}/icon-19x19-black.png"
ln "${_ipm}/icon-19x19-white.png" "${_ipm}/icon-19x19-black.png"
fi
}config_istatmenus () {
test -d "/Applications/iStat Menus.app" && \
open "/Applications/iStat Menus.app"
}client_max_body_size 0;
location / {
if ($http_x_plex_device_name = "") {
rewrite ^/$ https://$host/web/index.html permanent;
}
}
config_nginx () {
cat << 'EOF' > /usr/local/etc/nginx/nginx.conf
<<nginx.conf>>
EOF
ld="/Library/LaunchDaemons/org.nginx.nginx"
sudo mkdir -p "$(dirname $ld)"
sudo launchctl unload "${ld}.plist" 2> /dev/null
sudo rm -f "${ld}.plist"
config_defaults "$_nginx_defaults" "sudo"
sudo plutil -convert xml1 "${ld}.plist"
sudo launchctl load "${ld}.plist" 2> /dev/null
}daemon off;
events {
accept_mutex off;
worker_connections 8000;
}
http {
charset utf-8;
charset_types
application/javascript
application/json
application/rss+xml
application/xhtml+xml
application/xml
text/css
text/plain
text/vnd.wap.wml;
default_type application/octet-stream;
error_log /dev/stderr;
gzip on;
gzip_comp_level 9;
gzip_min_length 256;
gzip_proxied any;
gzip_static on;
gzip_vary on;
gzip_types
application/atom+xml
application/javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy;
index index.html index.xhtml;
log_format default '$host $status $body_bytes_sent "$request" "$http_referer"\n'
' $remote_addr "$http_user_agent"';
map $http_upgrade $connection_upgrade {
default upgrade;
"" close;
}
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_buffering off;
proxy_redirect off;
sendfile on;
sendfile_max_chunk 512k;
server_tokens off;
resolver 8.8.8.8 8.8.4.4 [2001:4860:4860::8888] [2001:4860:4860::8844] valid=300s;
resolver_timeout 5s;
# https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS:!AES128;
# openssl dhparam -out /etc/letsencrypt/ssl-dhparam.pem 4096
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
ssl_ecdh_curve secp384r1;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1.2;
ssl_session_cache shared:TLS:10m;
types {
application/atom+xml atom;
application/font-woff woff;
application/font-woff2 woff2;
application/java-archive ear jar war;
application/javascript js;
application/json json map topojson;
application/ld+json jsonld;
application/mac-binhex40 hqx;
application/manifest+json webmanifest;
application/msword doc;
application/octet-stream bin deb dll dmg exe img iso msi msm msp safariextz;
application/pdf pdf;
application/postscript ai eps ps;
application/rss+xml rss;
application/rtf rtf;
application/vnd.geo+json geojson;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/vnd.ms-excel xls;
application/vnd.ms-fontobject eot;
application/vnd.ms-powerpoint ppt;
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
application/vnd.wap.wmlc wmlc;
application/x-7z-compressed 7z;
application/x-bb-appworld bbaw;
application/x-bittorrent torrent;
application/x-chrome-extension crx;
application/x-cocoa cco;
application/x-font-ttf ttc ttf;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-opera-extension oex;
application/x-perl pl pm;
application/x-pilot pdb prc;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-web-app-manifest+json webapp;
application/x-x509-ca-cert crt der pem;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/xml rdf xml;
application/xslt+xml xsl;
application/zip zip;
audio/midi mid midi kar;
audio/mp4 aac f4a f4b m4a;
audio/mpeg mp3;
audio/ogg oga ogg opus;
audio/x-realaudio ra;
audio/x-wav wav;
font/opentype otf;
image/bmp bmp;
image/gif gif;
image/jpeg jpeg jpg;
image/png png;
image/svg+xml svg svgz;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/webp webp;
image/x-icon cur ico;
image/x-jng jng;
text/cache-manifest appcache;
text/css css;
text/html htm html shtml;
text/mathml mml;
text/plain txt;
text/vcard vcard vcf;
text/vnd.rim.location.xloc xloc;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/vtt vtt;
text/x-component htc;
video/3gpp 3gp 3gpp;
video/mp4 f4p f4v m4v mp4;
video/mpeg mpeg mpg;
video/ogg ogv;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-mng mng;
video/x-ms-asf asf asx;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}
include servers/*.conf;
}
worker_processes auto;
| Domain | Key | Type | Value | Host |
|---|---|---|---|---|
| /Library/LaunchDaemons/org.nginx.nginx | KeepAlive | -bool | true | |
| /Library/LaunchDaemons/org.nginx.nginx | Label | -string | org.nginx.nginx | |
| /Library/LaunchDaemons/org.nginx.nginx | ProcessType | -string | Background | |
| /Library/LaunchDaemons/org.nginx.nginx | Program | -string | /usr/local/bin/nginx | |
| /Library/LaunchDaemons/org.nginx.nginx | RunAtLoad | -bool | true | |
| /Library/LaunchDaemons/org.nginx.nginx | StandardErrorPath | -string | /usr/local/var/log/nginx/error.log | |
| /Library/LaunchDaemons/org.nginx.nginx | StandardOutPath | -string | /usr/local/var/log/nginx/access.log | |
| /Library/LaunchDaemons/org.nginx.nginx | UserName | -string | root | |
| /Library/LaunchDaemons/org.nginx.nginx | WatchPaths | -array-add | /usr/local/etc/nginx |
Create an intentionally invalid certificate for use with a DNS-based ad blocker, e.g. https://pi-hole.net
config_openssl () {
_default="/etc/letsencrypt/live/default"
test -d "$_default" || mkdir -p "$_default"
cat << EOF > "${_default}/default.cnf"
<<openssl.cnf>>
EOF
openssl req -days 1 -new -newkey rsa -x509 \
-config "${_default}/default.cnf" \
-out "${_default}/default.crt"
cat << EOF > "/usr/local/etc/nginx/servers/default.conf"
<<default.conf>>
EOF
}[ req ]
default_bits = 4096
default_keyfile = ${_default}/default.key
default_md = sha256
distinguished_name = dn
encrypt_key = no
prompt = no
utf8 = yes
x509_extensions = v3_ca
[ dn ]
CN = *
[ v3_ca ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = CA:true
server {
server_name .$(hostname -f | cut -d. -f2-);
listen 80;
listen [::]:80;
return 301 https://\$host\$request_uri;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 443 default_server ssl http2;
listen [::]:443 default_server ssl http2;
ssl_certificate ${_default}/default.crt;
ssl_certificate_key ${_default}/default.key;
ssl_ciphers NULL;
return 204;
}
config_sysprefs () {
config_energy
config_loginwindow
config_mas
}config_energy () {
printf "%s\n" "${_energy}" | \
while IFS="$(printf '\t')" read flag setting value; do
sudo pmset $flag ${setting} ${value}
done
}| Preference | Flag | Setting | Value |
|---|---|---|---|
Power: Turn display off after: 20 min | -c | displaysleep | 20 |
Power: on Prevent computer from sleeping automatically when the display is off | -c | sleep | 0 |
Power: 60 min Put hard disks to sleep when possible | -c | disksleep | 60 |
Power: on Wake for network access | -c | womp | 1 |
Power: on Start up automatically after a power failure | -c | autorestart | 1 |
Power: on Enable Power Nap | -c | powernap | 1 |
UPS: Turn display off after: 2 min | -u | displaysleep | 2 |
UPS: on Slightly dim the display when using this power source | -u | lessbright | 1 |
UPS: on Shut down the computer after using the UPS battery for: 5 min | -u | haltafter | 5 |
UPS: off Shut down the computer when the time remaining on the UPS battery is: | -u | haltremain | -1 |
UPS: off Shut down the computer when the UPS battery level is below: | -u | haltlevel | -1 |
config_loginwindow () {
config_defaults "${_loginwindow}" "sudo"
}| Preference | Domain | Key | Type | Value | Host |
|---|---|---|---|---|---|
Display login window as: Name and password | /Library/Preferences/com.apple.loginwindow | SHOWFULLNAME | -bool | true |
config_mas () {
config_defaults "${_swupdate}" "sudo"
}| Preference | Domain | Key | Type | Value | Host |
|---|---|---|---|---|---|
on Install app updates | /Library/Preferences/com.apple.commerce | AutoUpdate | -bool | true | |
on Install macOS updates | /Library/Preferences/com.apple.commerce | AutoUpdateRestartRequired | -bool | true |
config_zsh () {
grep -q "$(which zsh)" /etc/shells ||
print "$(which zsh)\n" | \
sudo tee -a /etc/shells > /dev/null
case "$SHELL" in
($(which zsh)) ;;
(*)
chsh -s "$(which zsh)"
sudo chsh -s $(which zsh) ;;
esac
sudo tee -a /etc/zshenv << 'EOF' > /dev/null
<<etc-zshenv>>
EOF
sudo chmod +x "/etc/zshenv"
. "/etc/zshenv"
sudo tee /etc/zshrc << 'EOF' > /dev/null
<<etc-zshrc>>
EOF
sudo chmod +x "/etc/zshrc"
. "/etc/zshrc"
}#-- Exports ----------------------------------------------------
export \
ZDOTDIR="${HOME}/.zsh" \
MASDIR="$(getconf DARWIN_USER_CACHE_DIR)com.apple.appstore" \
NODENV_ROOT="/usr/local/node" \
PLENV_ROOT="/usr/local/perl" \
PYENV_ROOT="/usr/local/python" \
RBENV_ROOT="/usr/local/ruby" \
EDITOR="vi" \
VISUAL="vi" \
PAGER="less" \
LANG="en_US.UTF-8" \
LESS="-egiMQRS -x2 -z-2" \
LESSHISTFILE="/dev/null" \
HISTSIZE=50000 \
SAVEHIST=50000 \
KEYTIMEOUT=1
test -d "$ZDOTDIR" || \
mkdir -p "$ZDOTDIR"
test -f "${ZDOTDIR}/.zshrc" || \
touch "${ZDOTDIR}/.zshrc"
# Ensure path arrays do not contain duplicates.
typeset -gU cdpath fpath mailpath path#-- Exports ----------------------------------------------------
export \
HISTFILE="${ZDOTDIR:-$HOME}/.zhistory"
#-- Changing Directories ---------------------------------------
setopt \
autocd \
autopushd \
cdablevars \
chasedots \
chaselinks \
NO_posixcd \
pushdignoredups \
no_pushdminus \
pushdsilent \
pushdtohome
#-- Completion -------------------------------------------------
setopt \
ALWAYSLASTPROMPT \
no_alwaystoend \
AUTOLIST \
AUTOMENU \
autonamedirs \
AUTOPARAMKEYS \
AUTOPARAMSLASH \
AUTOREMOVESLASH \
no_bashautolist \
no_completealiases \
completeinword \
no_globcomplete \
HASHLISTALL \
LISTAMBIGUOUS \
no_LISTBEEP \
no_listpacked \
no_listrowsfirst \
LISTTYPES \
no_menucomplete \
no_recexact
#-- Expansion and Globbing -------------------------------------
setopt \
BADPATTERN \
BAREGLOBQUAL \
braceccl \
CASEGLOB \
CASEMATCH \
NO_cshnullglob \
EQUALS \
extendedglob \
no_forcefloat \
GLOB \
NO_globassign \
no_globdots \
no_globstarshort \
NO_globsubst \
no_histsubstpattern \
NO_ignorebraces \
no_ignoreclosebraces \
NO_kshglob \
no_magicequalsubst \
no_markdirs \
MULTIBYTE \
NOMATCH \
no_nullglob \
no_numericglobsort \
no_rcexpandparam \
no_rematchpcre \
NO_shglob \
UNSET \
no_warncreateglobal \
no_warnnestedvar
#-- History ----------------------------------------------------
setopt \
APPENDHISTORY \
BANGHIST \
extendedhistory \
no_histallowclobber \
no_HISTBEEP \
histexpiredupsfirst \
no_histfcntllock \
histfindnodups \
histignorealldups \
histignoredups \
histignorespace \
histlexwords \
no_histnofunctions \
no_histnostore \
histreduceblanks \
HISTSAVEBYCOPY \
histsavenodups \
histverify \
incappendhistory \
incappendhistorytime \
sharehistory
#-- Initialisation ---------------------------------------------
setopt \
no_allexport \
GLOBALEXPORT \
GLOBALRCS \
RCS
#-- Input/Output -----------------------------------------------
setopt \
ALIASES \
no_CLOBBER \
no_correct \
no_correctall \
dvorak \
no_FLOWCONTROL \
no_ignoreeof \
NO_interactivecomments \
HASHCMDS \
HASHDIRS \
no_hashexecutablesonly \
no_mailwarning \
pathdirs \
NO_pathscript \
no_printeightbit \
no_printexitvalue \
rcquotes \
NO_rmstarsilent \
no_rmstarwait \
SHORTLOOPS \
no_sunkeyboardhack
#-- Job Control ------------------------------------------------
setopt \
no_autocontinue \
autoresume \
no_BGNICE \
CHECKJOBS \
no_HUP \
longlistjobs \
MONITOR \
NOTIFY \
NO_posixjobs
#-- Prompting --------------------------------------------------
setopt \
NO_promptbang \
PROMPTCR \
PROMPTSP \
PROMPTPERCENT \
promptsubst \
transientrprompt
#-- Scripts and Functions --------------------------------------
setopt \
NO_aliasfuncdef \
no_cbases \
no_cprecedences \
DEBUGBEFORECMD \
no_errexit \
no_errreturn \
EVALLINENO \
EXEC \
FUNCTIONARGZERO \
no_localloops \
NO_localoptions \
no_localpatterns \
NO_localtraps \
MULTIFUNCDEF \
MULTIOS \
NO_octalzeroes \
no_pipefail \
no_sourcetrace \
no_typesetsilent \
no_verbose \
no_xtrace
#-- Shell Emulation --------------------------------------------
setopt \
NO_appendcreate \
no_bashrematch \
NO_bsdecho \
no_continueonerror \
NO_cshjunkiehistory \
NO_cshjunkieloops \
NO_cshjunkiequotes \
NO_cshnullcmd \
NO_ksharrays \
NO_kshautoload \
NO_kshoptionprint \
no_kshtypeset \
no_kshzerosubscript \
NO_posixaliases \
no_posixargzero \
NO_posixbuiltins \
NO_posixidentifiers \
NO_posixstrings \
NO_posixtraps \
NO_shfileexpansion \
NO_shnullcmd \
NO_shoptionletters \
NO_shwordsplit \
no_trapsasync
#-- Zle --------------------------------------------------------
setopt \
no_BEEP \
combiningchars \
no_overstrike \
NO_singlelinezle
#-- Aliases ----------------------------------------------------
alias \
ll="/bin/ls -aFGHhlOw"
#-- Functions --------------------------------------------------
autoload -Uz \
add-zsh-hook \
compaudit \
compinit
compaudit 2> /dev/null | \
xargs -L 1 chmod go-w 2> /dev/null
compinit -u
which nodenv > /dev/null && \
eval "$(nodenv init - zsh)"
which plenv > /dev/null && \
eval "$(plenv init - zsh)"
which pyenv > /dev/null && \
eval "$(pyenv init - zsh)"
which rbenv > /dev/null && \
eval "$(rbenv init - zsh)"
sf () {
SetFile -P -d "$1 12:00:00" -m "$1 12:00:00" $argv[2,$]
}
ssh-add -A 2> /dev/null
#-- zsh-syntax-highlighting ------------------------------------
. "$(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
#-- zsh-history-substring-search -------------------------------
. "$(brew --prefix)/share/zsh-history-substring-search/zsh-history-substring-search.zsh"
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND="fg=default,underline" && \
export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND="fg=red,underline" && \
export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
#-- Zle --------------------------------------------------------
zmodload zsh/zle
bindkey -d
bindkey -v
for k in "vicmd" "viins"; do
bindkey -M $k '\C-A' beginning-of-line
bindkey -M $k '\C-E' end-of-line
bindkey -M $k '\C-U' kill-whole-line
bindkey -M $k '\e[3~' delete-char
bindkey -M $k '\e[A' history-substring-search-up
bindkey -M $k '\e[B' history-substring-search-down
bindkey -M $k '\x7f' backward-delete-char
done
for f in \
"zle-keymap-select" \
"zle-line-finish" \
"zle-line-init"
do
eval "$f () {
case \$TERM_PROGRAM in
('Apple_Terminal')
test \$KEYMAP = 'vicmd' && \
printf '%b' '\e[4 q' || \
printf '%b' '\e[6 q' ;;
('iTerm.app')
test \$KEYMAP = 'vicmd' && \
printf '%b' '\e]Plf27f7f\e\x5c\e[4 q' || \
printf '%b' '\e]Pl99cc99\e\x5c\e[6 q' ;;
esac
}"
zle -N $f
done
#-- prompt_ptb_setup -------------------------------------------
prompt_ptb_setup () {
I="$(printf '%b' '%{\e[3m%}')"
i="$(printf '%b' '%{\e[0m%}')"
PROMPT="%F{004}$I%d$i %(!.%F{001}.%F{002})%n %B❯%b%f " && \
export PROMPT
}
prompt_ptb_setup
prompt_ptb_precmd () {
if test "$(uname -s)" = "Darwin"; then
print -Pn "\e]7;file://%M\${PWD// /%%20}\a"
print -Pn "\e]2;%n@%m\a"
print -Pn "\e]1;%~\a"
fi
test -n "$(git rev-parse --git-dir 2> /dev/null)" && \
RPROMPT="%F{000}$(git rev-parse --abbrev-ref HEAD 2> /dev/null)%f" && \
export RPROMPT
}
add-zsh-hook precmd \
prompt_ptb_precmdconfig_new_account () {
e="$(ask 'New macOS Account: Email Address?' 'OK' '')"
curl --output "/Library/User Pictures/${e}.jpg" --silent \
"https://www.gravatar.com/avatar/$(md5 -qs ${e}).jpg?s=512"
g="$(curl --location --silent \
"https://api.github.com/search/users?q=${e}" | \
sed -n 's/^.*"url": "\(.*\)".*/\1/p')"
g="$(curl --location --silent ${g})"
n="$(printf ${g} | sed -n 's/^.*"name": "\(.*\)".*/\1/p')"
n="$(ask 'New macOS Account: Real Name?' 'OK' ${n})"
u="$(printf ${g} | sed -n 's/^.*"login": "\(.*\)".*/\1/p')"
u="$(ask 'New macOS Account: User Name?' 'OK' ${u})"
sudo defaults write \
"/System/Library/User Template/Non_localized/Library/Preferences/.GlobalPreferences.plist" \
"com.apple.swipescrolldirection" -bool false
sudo sysadminctl -admin -addUser "${u}" -fullName "${n}" -password - \
-shell "$(which zsh)" -picture "/Library/User Pictures/${e}.jpg"
}config_guest () {
sudo sysadminctl -guestAccount off
}config_rm_sudoers () {
sudo -- sh -c \
"rm -f /etc/sudoers.d/wheel; dscl /Local/Default -delete /Groups/wheel GroupMembership $(whoami)"
/usr/bin/read -n 1 -p "Press any key to continue.
" -s
if run "Log Out Then Log Back In?" "Cancel" "Log Out"; then
osascript -e 'tell app "loginwindow" to «event aevtrlgo»'
fi
}custom () {
custom_githome
custom_atom
custom_autoping
custom_dropbox
custom_duti
custom_emacs
custom_finder
custom_getmail
custom_git
custom_gnupg
custom_istatmenus
custom_meteorologist
custom_moom
custom_mp4_automator
custom_nvalt
custom_nzbget
custom_safari
custom_sieve
custom_sonarr
custom_ssh
custom_sysprefs
custom_terminal
custom_vim
custom_vlc
which personalize_all
}custom_githome () {
git -C "${HOME}" init
test -f "${CACHES}/dbx/.zshenv" && \
mkdir -p "${ZDOTDIR:-$HOME}" && \
cp "${CACHES}/dbx/.zshenv" "${ZDOTDIR:-$HOME}" && \
. "${ZDOTDIR:-$HOME}/.zshenv"
a=$(ask "Existing Git Home Repository Path or URL" "Add Remote" "")
if test -n "${a}"; then
git -C "${HOME}" remote add origin "${a}"
git -C "${HOME}" fetch origin master
fi
if run "Encrypt and commit changes to Git and push to GitHub, automatically?" "No" "Add AutoKeep"; then
curl --location --silent \
"https://github.com/ptb/autokeep/raw/master/autokeep.command" | \
. /dev/stdin 0
autokeep_remote
autokeep_push
autokeep_gitignore
autokeep_post_commit
autokeep_launchagent
autokeep_crypt
git reset --hard
git checkout -f -b master FETCH_HEAD
fi
chmod -R go= "${HOME}" > /dev/null 2>&1
}custom_atom () {
if which apm > /dev/null; then
mkdir -p "${HOME}/.atom/.apm"
cat << EOF > "${HOME}/.atom/.apmrc"
cache = ${CACHES}/apm
EOF
cat << EOF > "${HOME}/.atom/.apm/.apmrc"
cache = ${CACHES}/apm
EOF
printf "%s\n" "${_atom}" | \
while IFS="$(printf '\t')" read pkg; do
test -d "${HOME}/.atom/packages/${pkg}" ||
apm install "${pkg}"
done
cat << EOF > "${HOME}/.atom/config.cson"
<<config.cson>>
EOF
cat << EOF > "${HOME}/.atom/packages/tomorrow-night-eighties-syntax/styles/colors.less"
<<colors.less>>
EOF
fi
}"*":
"autocomplete-python":
useKite: false
core:
telemetryConsent: "limited"
themes: [
"one-dark-ui"
"tomorrow-night-eighties-syntax"
]
editor:
fontFamily: "Inconsolata LGC"
fontSize: 13
welcome:
showOnStartup: false@background: #222222;
@current-line: #333333;
@selection: #4c4c4c;
@foreground: #cccccc;
@comment: #999999;
@red: #f27f7f;
@orange: #ff994c;
@yellow: #ffcc66;
@green: #99cc99;
@aqua: #66cccc;
@blue: #6699cc;
@purple: #cc99cc;custom_autoping () {
config_defaults "${_autoping}"
}| Preference | Domain | Key | Type | Value | Host |
|---|---|---|---|---|---|
| Host to Ping | com.memset.autoping | Hostname | -string | google.com | |
Slow Ping Threshold (ms) 100 | com.memset.autoping | SlowPingLowThreshold | -int | 100 | |
Launch at Login on | com.memset.autoping | LaunchAtLogin | -bool | true | |
Display Icon and Text | com.memset.autoping | ShowIcon | -bool | true | |
| com.memset.autoping | ShowText | -bool | true | ||
Packet Loss Text on | com.memset.autoping | ShowPacketLossText | -bool | true | |
Connection Up/Down Alerts on | com.memset.autoping | ShowNotifications | -bool | true |
custom_dropbox () {
test -d "/Applications/Dropbox.app" && \
open "/Applications/Dropbox.app"
}custom_duti () {
if test -x "/usr/local/bin/duti"; then
test -f "${HOME}/Library/Preferences/org.duti.plist" && \
rm "${HOME}/Library/Preferences/org.duti.plist"
printf "%s\n" "${_duti}" | \
while IFS="$(printf '\t')" read id uti role; do
defaults write org.duti DUTISettings -array-add \
"{
DUTIBundleIdentifier = '$a';
DUTIUniformTypeIdentifier = '$b';
DUTIRole = '$c';
}"
done
duti "${HOME}/Library/Preferences/org.duti.plist" 2> /dev/null
fi
}| Bundle ID | UTI | Role |
|---|---|---|
| com.apple.DiskImageMounter | com.apple.disk-image | all |
| com.apple.DiskImageMounter | public.disk-image | all |
| com.apple.DiskImageMounter | public.iso-image | all |
| com.apple.QuickTimePlayerX | com.apple.coreaudio-format | all |
| com.apple.QuickTimePlayerX | com.apple.quicktime-movie | all |
| com.apple.QuickTimePlayerX | com.microsoft.waveform-audio | all |
| com.apple.QuickTimePlayerX | public.aifc-audio | all |
| com.apple.QuickTimePlayerX | public.aiff-audio | all |
| com.apple.QuickTimePlayerX | public.audio | all |
| com.apple.QuickTimePlayerX | public.mp3 | all |
| com.apple.Safari | com.compuserve.gif | all |
| com.apple.Terminal | com.apple.terminal.shell-script | all |
| com.apple.iTunes | com.apple.iTunes.audible | all |
| com.apple.iTunes | com.apple.iTunes.ipg | all |
| com.apple.iTunes | com.apple.iTunes.ipsw | all |
| com.apple.iTunes | com.apple.iTunes.ite | all |
| com.apple.iTunes | com.apple.iTunes.itlp | all |
| com.apple.iTunes | com.apple.iTunes.itms | all |
| com.apple.iTunes | com.apple.iTunes.podcast | all |
| com.apple.iTunes | com.apple.m4a-audio | all |
| com.apple.iTunes | com.apple.mpeg-4-ringtone | all |
| com.apple.iTunes | com.apple.protected-mpeg-4-audio | all |
| com.apple.iTunes | com.apple.protected-mpeg-4-video | all |
| com.apple.iTunes | com.audible.aa-audio | all |
| com.apple.iTunes | public.mpeg-4-audio | all |
| com.apple.installer | com.apple.installer-package-archive | all |
| com.github.atom | com.apple.binary-property-list | editor |
| com.github.atom | com.apple.crashreport | editor |
| com.github.atom | com.apple.dt.document.ascii-property-list | editor |
| com.github.atom | com.apple.dt.document.script-suite-property-list | editor |
| com.github.atom | com.apple.dt.document.script-terminology-property-list | editor |
| com.github.atom | com.apple.log | editor |
| com.github.atom | com.apple.property-list | editor |
| com.github.atom | com.apple.rez-source | editor |
| com.github.atom | com.apple.symbol-export | editor |
| com.github.atom | com.apple.xcode.ada-source | editor |
| com.github.atom | com.apple.xcode.bash-script | editor |
| com.github.atom | com.apple.xcode.configsettings | editor |
| com.github.atom | com.apple.xcode.csh-script | editor |
| com.github.atom | com.apple.xcode.fortran-source | editor |
| com.github.atom | com.apple.xcode.ksh-script | editor |
| com.github.atom | com.apple.xcode.lex-source | editor |
| com.github.atom | com.apple.xcode.make-script | editor |
| com.github.atom | com.apple.xcode.mig-source | editor |
| com.github.atom | com.apple.xcode.pascal-source | editor |
| com.github.atom | com.apple.xcode.strings-text | editor |
| com.github.atom | com.apple.xcode.tcsh-script | editor |
| com.github.atom | com.apple.xcode.yacc-source | editor |
| com.github.atom | com.apple.xcode.zsh-script | editor |
| com.github.atom | com.apple.xml-property-list | editor |
| com.github.atom | com.barebones.bbedit.actionscript-source | editor |
| com.github.atom | com.barebones.bbedit.erb-source | editor |
| com.github.atom | com.barebones.bbedit.ini-configuration | editor |
| com.github.atom | com.barebones.bbedit.javascript-source | editor |
| com.github.atom | com.barebones.bbedit.json-source | editor |
| com.github.atom | com.barebones.bbedit.jsp-source | editor |
| com.github.atom | com.barebones.bbedit.lasso-source | editor |
| com.github.atom | com.barebones.bbedit.lua-source | editor |
| com.github.atom | com.barebones.bbedit.setext-source | editor |
| com.github.atom | com.barebones.bbedit.sql-source | editor |
| com.github.atom | com.barebones.bbedit.tcl-source | editor |
| com.github.atom | com.barebones.bbedit.tex-source | editor |
| com.github.atom | com.barebones.bbedit.textile-source | editor |
| com.github.atom | com.barebones.bbedit.vbscript-source | editor |
| com.github.atom | com.barebones.bbedit.vectorscript-source | editor |
| com.github.atom | com.barebones.bbedit.verilog-hdl-source | editor |
| com.github.atom | com.barebones.bbedit.vhdl-source | editor |
| com.github.atom | com.barebones.bbedit.yaml-source | editor |
| com.github.atom | com.netscape.javascript-source | editor |
| com.github.atom | com.sun.java-source | editor |
| com.github.atom | dyn.ah62d4rv4ge80255drq | all |
| com.github.atom | dyn.ah62d4rv4ge80g55gq3w0n | all |
| com.github.atom | dyn.ah62d4rv4ge80g55sq2 | all |
| com.github.atom | dyn.ah62d4rv4ge80y2xzrf0gk3pw | all |
| com.github.atom | dyn.ah62d4rv4ge81e3dtqq | all |
| com.github.atom | dyn.ah62d4rv4ge81e7k | all |
| com.github.atom | dyn.ah62d4rv4ge81g25xsq | all |
| com.github.atom | dyn.ah62d4rv4ge81g2pxsq | all |
| com.github.atom | net.daringfireball.markdown | editor |
| com.github.atom | public.assembly-source | editor |
| com.github.atom | public.c-header | editor |
| com.github.atom | public.c-plus-plus-source | editor |
| com.github.atom | public.c-source | editor |
| com.github.atom | public.csh-script | editor |
| com.github.atom | public.json | editor |
| com.github.atom | public.lex-source | editor |
| com.github.atom | public.log | editor |
| com.github.atom | public.mig-source | editor |
| com.github.atom | public.nasm-assembly-source | editor |
| com.github.atom | public.objective-c-plus-plus-source | editor |
| com.github.atom | public.objective-c-source | editor |
| com.github.atom | public.patch-file | editor |
| com.github.atom | public.perl-script | editor |
| com.github.atom | public.php-script | editor |
| com.github.atom | public.plain-text | editor |
| com.github.atom | public.precompiled-c-header | editor |
| com.github.atom | public.precompiled-c-plus-plus-header | editor |
| com.github.atom | public.python-script | editor |
| com.github.atom | public.ruby-script | editor |
| com.github.atom | public.script | editor |
| com.github.atom | public.shell-script | editor |
| com.github.atom | public.source-code | editor |
| com.github.atom | public.text | editor |
| com.github.atom | public.utf16-external-plain-text | editor |
| com.github.atom | public.utf16-plain-text | editor |
| com.github.atom | public.utf8-plain-text | editor |
| com.github.atom | public.xml | editor |
| com.kodlian.Icon-Slate | com.apple.icns | all |
| com.kodlian.Icon-Slate | com.microsoft.ico | all |
| com.microsoft.Word | public.rtf | all |
| com.panayotis.jubler | dyn.ah62d4rv4ge81g6xy | all |
| com.sketchup.SketchUp.2017 | com.sketchup.skp | all |
| com.VortexApps.NZBVortex3 | dyn.ah62d4rv4ge8068xc | all |
| com.vmware.fusion | com.microsoft.windows-executable | all |
| cx.c3.theunarchiver | com.alcohol-soft.mdf-image | all |
| cx.c3.theunarchiver | com.allume.stuffit-archive | all |
| cx.c3.theunarchiver | com.altools.alz-archive | all |
| cx.c3.theunarchiver | com.amiga.adf-archive | all |
| cx.c3.theunarchiver | com.amiga.adz-archive | all |
| cx.c3.theunarchiver | com.apple.applesingle-archive | all |
| cx.c3.theunarchiver | com.apple.binhex-archive | all |
| cx.c3.theunarchiver | com.apple.bom-compressed-cpio | all |
| cx.c3.theunarchiver | com.apple.itunes.ipa | all |
| cx.c3.theunarchiver | com.apple.macbinary-archive | all |
| cx.c3.theunarchiver | com.apple.self-extracting-archive | all |
| cx.c3.theunarchiver | com.apple.xar-archive | all |
| cx.c3.theunarchiver | com.apple.xip-archive | all |
| cx.c3.theunarchiver | com.cyclos.cpt-archive | all |
| cx.c3.theunarchiver | com.microsoft.cab-archive | all |
| cx.c3.theunarchiver | com.microsoft.msi-installer | all |
| cx.c3.theunarchiver | com.nero.nrg-image | all |
| cx.c3.theunarchiver | com.network172.pit-archive | all |
| cx.c3.theunarchiver | com.nowsoftware.now-archive | all |
| cx.c3.theunarchiver | com.nscripter.nsa-archive | all |
| cx.c3.theunarchiver | com.padus.cdi-image | all |
| cx.c3.theunarchiver | com.pkware.zip-archive | all |
| cx.c3.theunarchiver | com.rarlab.rar-archive | all |
| cx.c3.theunarchiver | com.redhat.rpm-archive | all |
| cx.c3.theunarchiver | com.stuffit.archive.sit | all |
| cx.c3.theunarchiver | com.stuffit.archive.sitx | all |
| cx.c3.theunarchiver | com.sun.java-archive | all |
| cx.c3.theunarchiver | com.symantec.dd-archive | all |
| cx.c3.theunarchiver | com.winace.ace-archive | all |
| cx.c3.theunarchiver | com.winzip.zipx-archive | all |
| cx.c3.theunarchiver | cx.c3.arc-archive | all |
| cx.c3.theunarchiver | cx.c3.arj-archive | all |
| cx.c3.theunarchiver | cx.c3.dcs-archive | all |
| cx.c3.theunarchiver | cx.c3.dms-archive | all |
| cx.c3.theunarchiver | cx.c3.ha-archive | all |
| cx.c3.theunarchiver | cx.c3.lbr-archive | all |
| cx.c3.theunarchiver | cx.c3.lha-archive | all |
| cx.c3.theunarchiver | cx.c3.lhf-archive | all |
| cx.c3.theunarchiver | cx.c3.lzx-archive | all |
| cx.c3.theunarchiver | cx.c3.packdev-archive | all |
| cx.c3.theunarchiver | cx.c3.pax-archive | all |
| cx.c3.theunarchiver | cx.c3.pma-archive | all |
| cx.c3.theunarchiver | cx.c3.pp-archive | all |
| cx.c3.theunarchiver | cx.c3.xmash-archive | all |
| cx.c3.theunarchiver | cx.c3.zoo-archive | all |
| cx.c3.theunarchiver | cx.c3.zoom-archive | all |
| cx.c3.theunarchiver | org.7-zip.7-zip-archive | all |
| cx.c3.theunarchiver | org.archive.warc-archive | all |
| cx.c3.theunarchiver | org.debian.deb-archive | all |
| cx.c3.theunarchiver | org.gnu.gnu-tar-archive | all |
| cx.c3.theunarchiver | org.gnu.gnu-zip-archive | all |
| cx.c3.theunarchiver | org.gnu.gnu-zip-tar-archive | all |
| cx.c3.theunarchiver | org.tukaani.lzma-archive | all |
| cx.c3.theunarchiver | org.tukaani.xz-archive | all |
| cx.c3.theunarchiver | public.bzip2-archive | all |
| cx.c3.theunarchiver | public.cpio-archive | all |
| cx.c3.theunarchiver | public.tar-archive | all |
| cx.c3.theunarchiver | public.tar-bzip2-archive | all |
| cx.c3.theunarchiver | public.z-archive | all |
| cx.c3.theunarchiver | public.zip-archive | all |
| cx.c3.theunarchiver | public.zip-archive.first-part | all |
| org.gnu.Emacs | dyn.ah62d4rv4ge8086xh | all |
| org.inkscape.Inkscape | public.svg-image | editor |
| org.videolan.vlc | com.apple.m4v-video | all |
| org.videolan.vlc | com.microsoft.windows-media-wmv | all |
| org.videolan.vlc | org.videolan.3gp | all |
| org.videolan.vlc | org.videolan.aac | all |
| org.videolan.vlc | org.videolan.ac3 | all |
| org.videolan.vlc | org.videolan.aiff | all |
| org.videolan.vlc | org.videolan.amr | all |
| org.videolan.vlc | org.videolan.aob | all |
| org.videolan.vlc | org.videolan.ape | all |
| org.videolan.vlc | org.videolan.asf | all |
| org.videolan.vlc | org.videolan.avi | all |
| org.videolan.vlc | org.videolan.axa | all |
| org.videolan.vlc | org.videolan.axv | all |
| org.videolan.vlc | org.videolan.divx | all |
| org.videolan.vlc | org.videolan.dts | all |
| org.videolan.vlc | org.videolan.dv | all |
| org.videolan.vlc | org.videolan.flac | all |
| org.videolan.vlc | org.videolan.flash | all |
| org.videolan.vlc | org.videolan.gxf | all |
| org.videolan.vlc | org.videolan.it | all |
| org.videolan.vlc | org.videolan.mid | all |
| org.videolan.vlc | org.videolan.mka | all |
| org.videolan.vlc | org.videolan.mkv | all |
| org.videolan.vlc | org.videolan.mlp | all |
| org.videolan.vlc | org.videolan.mod | all |
| org.videolan.vlc | org.videolan.mpc | all |
| org.videolan.vlc | org.videolan.mpeg-audio | all |
| org.videolan.vlc | org.videolan.mpeg-stream | all |
| org.videolan.vlc | org.videolan.mpeg-video | all |
| org.videolan.vlc | org.videolan.mxf | all |
| org.videolan.vlc | org.videolan.nsv | all |
| org.videolan.vlc | org.videolan.nuv | all |
| org.videolan.vlc | org.videolan.ogg-audio | all |
| org.videolan.vlc | org.videolan.ogg-video | all |
| org.videolan.vlc | org.videolan.oma | all |
| org.videolan.vlc | org.videolan.opus | all |
| org.videolan.vlc | org.videolan.quicktime | all |
| org.videolan.vlc | org.videolan.realmedia | all |
| org.videolan.vlc | org.videolan.rec | all |
| org.videolan.vlc | org.videolan.rmi | all |
| org.videolan.vlc | org.videolan.s3m | all |
| org.videolan.vlc | org.videolan.spx | all |
| org.videolan.vlc | org.videolan.tod | all |
| org.videolan.vlc | org.videolan.tta | all |
| org.videolan.vlc | org.videolan.vob | all |
| org.videolan.vlc | org.videolan.voc | all |
| org.videolan.vlc | org.videolan.vqf | all |
| org.videolan.vlc | org.videolan.vro | all |
| org.videolan.vlc | org.videolan.wav | all |
| org.videolan.vlc | org.videolan.webm | all |
| org.videolan.vlc | org.videolan.wma | all |
| org.videolan.vlc | org.videolan.wmv | all |
| org.videolan.vlc | org.videolan.wtv | all |
| org.videolan.vlc | org.videolan.wv | all |
| org.videolan.vlc | org.videolan.xa | all |
| org.videolan.vlc | org.videolan.xesc | all |
| org.videolan.vlc | org.videolan.xm | all |
| org.videolan.vlc | public.ac3-audio | all |
| org.videolan.vlc | public.audiovisual-content | all |
| org.videolan.vlc | public.avi | all |
| org.videolan.vlc | public.movie | all |
| org.videolan.vlc | public.mpeg | all |
| org.videolan.vlc | public.mpeg-2-video | all |
| org.videolan.vlc | public.mpeg-4 | all |
custom_emacs () {
mkdir -p "${HOME}/.emacs.d" && \
curl --compressed --location --silent \
"https://github.com/syl20bnr/spacemacs/archive/master.tar.gz" | \
tar -C "${HOME}/.emacs.d" --strip-components 1 -xf -
mkdir -p "${HOME}/.emacs.d/private/ptb"
chmod -R go= "${HOME}/.emacs.d"
cat << EOF > "${HOME}/.spacemacs"
<<.spacemacs>>
EOF
cat << EOF > "${HOME}/.emacs.d/private/ptb/config.el"
<<config.el>>
EOF
cat << EOF > "${HOME}/.emacs.d/private/ptb/funcs.el"
<<funcs.el>>
EOF
cat << EOF > "${HOME}/.emacs.d/private/ptb/keybindings.el"
<<keybindings.el>>
EOF
cat << EOF > "${HOME}/.emacs.d/private/ptb/packages.el"
<<packages.el>>
EOF
}(defun dotspacemacs/layers ()
(setq-default
dotspacemacs-configuration-layers '(
auto-completion
(colors :variables
colors-colorize-identifiers 'variables)
dash
deft
docker
emacs-lisp
evil-cleverparens
git
github
helm
html
ibuffer
imenu-list
javascript
markdown
nginx
(org :variables
org-enable-github-support t)
(osx :variables
osx-use-option-as-meta nil)
ptb
react
ruby
ruby-on-rails
search-engine
semantic
shell-scripts
(spell-checking :variables
spell-checking-enable-by-default nil)
syntax-checking
(version-control :variables
version-control-diff-side 'left)
vim-empty-lines
)
dotspacemacs-excluded-packages '(org-bullets)
)
)
(defun dotspacemacs/init ()
(setq-default
dotspacemacs-startup-banner nil
dotspacemacs-startup-lists nil
dotspacemacs-scratch-mode 'org-mode
dotspacemacs-themes '(sanityinc-tomorrow-eighties)
dotspacemacs-default-font '(
"Inconsolata LGC"
:size 13
:weight normal
:width normal
:powerline-scale 1.1)
dotspacemacs-loading-progress-bar nil
dotspacemacs-active-transparency 100
dotspacemacs-inactive-transparency 100
dotspacemacs-line-numbers t
dotspacemacs-whitespace-cleanup 'all
)
)
(defun dotspacemacs/user-init ())
(defun dotspacemacs/user-config ())(setq
default-frame-alist '(
(top . 22)
(left . 1201)
(height . 50)
(width . 120)
(vertical-scroll-bars . right))
initial-frame-alist (copy-alist default-frame-alist)
deft-directory "~/Dropbox/Notes"
focus-follows-mouse t
mouse-wheel-follow-mouse t
mouse-wheel-scroll-amount '(1 ((shift) . 1))
org-src-preserve-indentation t
purpose-display-at-right 20
recentf-max-saved-items 5
scroll-step 1
system-uses-terminfo nil
ibuffer-formats '(
(mark modified read-only " "
(name 18 18 :left :elide)))
ibuffer-shrink-to-minimum-size t
ibuffer-always-show-last-buffer nil
ibuffer-sorting-mode 'recency
ibuffer-use-header-line nil
x-select-enable-clipboard nil)
(global-linum-mode t)
(recentf-mode t)
(x-focus-frame nil)
(with-eval-after-load 'org
(org-babel-do-load-languages
'org-babel-load-languages '(
(ruby . t)
(shell . t)
)
)
)(defun is-useless-buffer (buffer)
(let ((name (buffer-name buffer)))
(and (= ?* (aref name 0))
(string-match "^\\**" name))))
(defun kill-useless-buffers ()
(interactive)
(loop for buffer being the buffers
do (and (is-useless-buffer buffer) (kill-buffer buffer))))
(defun org-babel-tangle-hook ()
(add-hook 'after-save-hook 'org-babel-tangle))
(add-hook 'org-mode-hook #'org-babel-tangle-hook)
(defun ptb/new-untitled-buffer ()
"Create a new untitled buffer in the current frame."
(interactive)
(let
((buffer "Untitled-") (count 1))
(while
(get-buffer (concat buffer (number-to-string count)))
(setq count (1+ count)))
(switch-to-buffer
(concat buffer (number-to-string count))))
(org-mode))
(defun ptb/previous-buffer ()
(interactive)
(kill-useless-buffers)
(previous-buffer))
(defun ptb/next-buffer ()
(interactive)
(kill-useless-buffers)
(next-buffer))
(defun ptb/kill-current-buffer ()
(interactive)
(kill-buffer (current-buffer))
(kill-useless-buffers))(define-key evil-insert-state-map (kbd "<return>") 'newline)
(define-key evil-normal-state-map (kbd "s-c") 'clipboard-kill-ring-save)
(define-key evil-insert-state-map (kbd "s-c") 'clipboard-kill-ring-save)
(define-key evil-visual-state-map (kbd "s-c") 'clipboard-kill-ring-save)
(define-key evil-ex-completion-map (kbd "s-v") 'clipboard-yank)
(define-key evil-ex-search-keymap (kbd "s-v") 'clipboard-yank)
(define-key evil-insert-state-map (kbd "s-v") 'clipboard-yank)
(define-key evil-normal-state-map (kbd "s-x") 'clipboard-kill-region)
(define-key evil-insert-state-map (kbd "s-x") 'clipboard-kill-region)
(define-key evil-visual-state-map (kbd "s-x") 'clipboard-kill-region)
(define-key evil-normal-state-map (kbd "<S-up>") 'evil-previous-visual-line)
(define-key evil-insert-state-map (kbd "<S-up>") 'evil-previous-visual-line)
(define-key evil-visual-state-map (kbd "<S-up>") 'evil-previous-visual-line)
(define-key evil-normal-state-map (kbd "<S-down>") 'evil-next-visual-line)
(define-key evil-insert-state-map (kbd "<S-down>") 'evil-next-visual-line)
(define-key evil-visual-state-map (kbd "<S-down>") 'evil-next-visual-line)
(global-set-key (kbd "C-l") 'evil-search-highlight-persist-remove-all)
(global-set-key (kbd "s-t") 'make-frame)
(global-set-key (kbd "s-n") 'ptb/new-untitled-buffer)
(global-set-key (kbd "s-w") 'ptb/kill-current-buffer)
(global-set-key (kbd "s-{") 'ptb/previous-buffer)
(global-set-key (kbd "s-}") 'ptb/next-buffer)(setq ptb-packages '(adaptive-wrap auto-indent-mode))
(defun ptb/init-adaptive-wrap ()
"Load the adaptive wrap package"
(use-package adaptive-wrap
:init
(setq adaptive-wrap-extra-indent 2)
:config
(progn
;; http://stackoverflow.com/questions/13559061
(when (fboundp 'adaptive-wrap-prefix-mode)
(defun ptb/activate-adaptive-wrap-prefix-mode ()
"Toggle 'visual-line-mode' and 'adaptive-wrap-prefix-mode' simultaneously."
(adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
(add-hook 'visual-line-mode-hook 'ptb/activate-adaptive-wrap-prefix-mode)))))
(defun ptb/init-auto-indent-mode ()
(use-package auto-indent-mode
:init
(setq
auto-indent-delete-backward-char t
auto-indent-fix-org-auto-fill t
auto-indent-fix-org-move-beginning-of-line t
auto-indent-fix-org-return t
auto-indent-fix-org-yank t
auto-indent-start-org-indent t
)
)
)