diff --git a/setup/macos/El Capitan/Utilities.plist b/setup/macos/El Capitan/Utilities.plist new file mode 100644 index 00000000..89304181 --- /dev/null +++ b/setup/macos/El Capitan/Utilities.plist @@ -0,0 +1,69 @@ + + + + + Buttons + + + BundlePath + /Applications/iTerm.app + DescriptionKey + Hardware Diagnostics + Path + /Applications/iTerm.app/Contents/MacOS/iTerm2 + TitleKey + WizardKit: Hardware Diagnostics + + + BundlePath + /Applications/Utilities/Disk Utility.app + DescriptionKey + Repair or erase a volume. + Path + /Applications/Utilities/Disk Utility.app/Contents/MacOS/Disk Utility + TitleKey + Disk Utility + + + Menu + + + BundlePath + /Applications/Utilities/Firmware Password Utility.app + Path + /Applications/Utilities/Firmware Password Utility.app/Contents/MacOS/Firmware Password Utility + TitleKey + Firmware Password Utility + + + BundlePath + /System/Library/CoreServices/Applications/Network Utility.app + Path + /System/Library/CoreServices/Applications/Network Utility.app/Contents/MacOS/Network Utility + TitleKey + Network Utility + + + BundlePath + /System/Library/CoreServices/Applications/RAID Utility.app + Path + /System/Library/CoreServices/Applications/RAID Utility.app/Contents/MacOS/RAID Utility + Show If + + Selector + shouldShowRAIDUtility + + TitleKey + RAID Utility + + + BundlePath + /Applications/Utilities/Terminal.app + Path + /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal + TitleKey + Terminal + + + + diff --git a/setup/macos/El Capitan/com.googlecode.iterm2.plist b/setup/macos/El Capitan/com.googlecode.iterm2.plist new file mode 100644 index 00000000..71eb86a8 Binary files /dev/null and b/setup/macos/El Capitan/com.googlecode.iterm2.plist differ diff --git a/setup/macos/Utilities.plist b/setup/macos/Utilities.plist new file mode 100644 index 00000000..6d492017 --- /dev/null +++ b/setup/macos/Utilities.plist @@ -0,0 +1,69 @@ + + + + + Buttons + + + BundlePath + /Applications/iTerm-2.app + DescriptionKey + Hardware Diagnostics + Path + /Applications/iTerm-2.app/Contents/MacOS/iTerm2 + TitleKey + WizardKit: Hardware Diagnostics + + + BundlePath + /Applications/Utilities/Disk Utility.app + DescriptionKey + Repair or erase a volume. + Path + /Applications/Utilities/Disk Utility.app/Contents/MacOS/Disk Utility + TitleKey + Disk Utility + + + Menu + + + BundlePath + /Applications/Utilities/Firmware Password Utility.app + Path + /Applications/Utilities/Firmware Password Utility.app/Contents/MacOS/Firmware Password Utility + TitleKey + Firmware Password Utility + + + BundlePath + /System/Library/CoreServices/Applications/Network Utility.app + Path + /System/Library/CoreServices/Applications/Network Utility.app/Contents/MacOS/Network Utility + TitleKey + Network Utility + + + BundlePath + /System/Library/CoreServices/Applications/RAID Utility.app + Path + /System/Library/CoreServices/Applications/RAID Utility.app/Contents/MacOS/RAID Utility + Show If + + Selector + shouldShowRAIDUtility + + TitleKey + RAID Utility + + + BundlePath + /Applications/Utilities/Terminal.app + Path + /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal + TitleKey + Terminal + + + + diff --git a/setup/macos/aliases b/setup/macos/aliases new file mode 100644 index 00000000..4c91d8e6 --- /dev/null +++ b/setup/macos/aliases @@ -0,0 +1,16 @@ +alias cdtmp='cd "$(mktemp -d)"' +alias du='du -sch' +alias fix-perms='find -type d -exec chmod 755 "{}" \; && find -type f -exec chmod 644 "{}" \;' +alias less='less -S' +alias mkdir='mkdir -p' +alias mv='mv -nv' +alias q1=' ls -1' +alias q1a=' ls -1A' +alias q=' ls -lh' +alias qa=' ls -lAh' +alias qs=' ls' +alias qsa=' ls -A' +alias rm='rm -v' +alias rmdirs='find -depth -mindepth 1 -type d -exec rmdir "{}" --ignore-fail-on-non-empty \;' +alias tmux='tmux -f /etc/tmux.conf -S /Volumes/RAM_Disk/.tmux.socket' +alias vim='vim -u /.vimrc' diff --git a/setup/macos/bashrc b/setup/macos/bashrc new file mode 100644 index 00000000..421cd315 --- /dev/null +++ b/setup/macos/bashrc @@ -0,0 +1,14 @@ +export HOME=/Volumes/RAM_Disk + +# Set Locale +LC_ALL=en_US.UTF-8; export LC_ALL +LANG=en_US.UTF-8; export LANG + +# Set PATH +for p in /usr{/local/opt/{e2fsprogs,ruby,util-linux},/local,}/{bin,sbin}; do + PATH="${p}:${PATH}" +done +export PATH + +# Aliases +source /.aliases diff --git a/setup/macos/com.googlecode.iterm2.plist b/setup/macos/com.googlecode.iterm2.plist new file mode 100644 index 00000000..f851e10d Binary files /dev/null and b/setup/macos/com.googlecode.iterm2.plist differ diff --git a/setup/macos/live-macos-startup b/setup/macos/live-macos-startup new file mode 100755 index 00000000..f6c7a043 --- /dev/null +++ b/setup/macos/live-macos-startup @@ -0,0 +1,25 @@ +#!/bin/bash +# +## Init macOS env + +# Set Locale +LC_ALL=en_US.UTF-8; export LC_ALL +LANG=en_US.UTF-8; export LANG + +# Set PATH +for p in /usr{/local/opt/{e2fsprogs,ruby,util-linux},/local,}/{bin,sbin}; do + PATH="${p}:${PATH}" +done +export PATH + +# Create and mount RAMDisk +if ! [ -d /Volumes/RAM_Disk ]; then + diskutil erasevolume HFS+ RAM_Disk $(hdiutil attach -nomount ram://524288) +fi +cd /Volumes/RAM_Disk + +# Stay awake +caffeinate -id & + +# Run cmd +"$1" diff --git a/setup/macos/update-base-image b/setup/macos/update-base-image new file mode 100755 index 00000000..59015015 --- /dev/null +++ b/setup/macos/update-base-image @@ -0,0 +1,100 @@ +#!/bin/bash +# +## Update BaseImage for use as WK + +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail + +# Prep +echo "Initializing..." +BASE_IMAGE="$1" +IMAGE_DEV="$(hdiutil attach "${BASE_IMAGE}" | grep -Eo '(/dev/disk[0-9]+)\b')" +OS_VERSION="$(ls /Volumes/*Base\ System | grep -E 'OS X|macOS' | sed -E 's/Install (OS X|macOS) (.*)\.app/\2/')" +OUT_NAME="${HOME}/Desktop/WK ${OS_VERSION} ($(date +"%Y-%m-%d"))" +WK_PATH="/Volumes/WK_UFD" + +# Convert to a 4 GB R/W image +echo "Creating read-write copy of the ${OS_VERSION} Base System image..." +hdiutil create -srcdevice "${IMAGE_DEV}s1" -format UDSB "${OUT_NAME}.sparsebundle" +hdiutil detach "${IMAGE_DEV}" +hdiutil resize -size 4g "${OUT_NAME}.sparsebundle" +hdiutil attach "${OUT_NAME}.sparsebundle" +diskutil rename "OS X Base System" "WK_UFD" + +# Remove Install app +echo "Removing Install app..." +rm -R "${WK_PATH}"/Install*.app + +# Update Utilities menu +echo "Updating Utilities menu..." +if [[ "${OS_VERSION}" == "El Capitan" ]]; then + cp -a "El Capitan/Utilities.plist" "${WK_PATH}/System/Installation/CDIS/OS X Utilities.app/Contents/Resources/Utilities.plist" +else + cp -a Utilities.plist "${WK_PATH}/System/Installation/CDIS/macOS Utilities.app/Contents/Resources/Utilities.plist" +fi + +# Homebrew +echo "Installing Hombrew..." +mkdir -p "${WK_PATH}/usr/local/bin" +ln -s python3 "${WK_PATH}/usr/local/bin/python" +rsync -aS /opt/ "${WK_PATH}/opt"/ +rsync -aS --exclude='.git*' /usr/local/{Cellar,Frameworks,Homebrew,bin,etc,include,lib,libexec,opt,sbin,share,var} "${WK_PATH}/usr/local"/ + +# Fonts +echo "Installing Fonts..." +cp -a /Library/Fonts/Inconsolata*ttf "${WK_PATH}/System/Library/Fonts"/ + +# iTerm2 +echo "Installing iTerm2..." +if [[ "${OS_VERSION}" == "El Capitan" ]]; then + rsync -aS /Applications/iTerm.app "${WK_PATH}/Applications"/ + rsync -aS "El Capitan/com.googlecode.iterm2.plist" "${WK_PATH}/var/root/Library/Preferences"/ +else + rsync -aS /Applications/iTerm-2.app "${WK_PATH}/Applications"/ + rsync -aS com.googlecode.iterm2.plist "${WK_PATH}/var/root/Library/Preferences"/ + rsync -aS /usr/lib/lib{apr,expat,ffi}* /Volumes/WK_UFD/usr/lib/ + rsync -aS /System/Library/Frameworks/{MetalKit,Quartz*}.framework "${WK_PATH}/System/Library/Frameworks"/ +fi +cp -a ../linux/include/airootfs/etc/skel/.tmux.conf "${WK_PATH}/etc/tmux.conf" +rsync -aS /System/Library/Colors/System.clr "${WK_PATH}/System/Library/Colors"/ +rsync -aS /System/Library/Frameworks/{Scripting,ScriptingBridge,LocalAuthentication}.framework "${WK_PATH}/System/Library/Frameworks"/ +rsync -aS /usr/bin/locale "${WK_PATH}/usr/bin"/ +rsync -aLS /usr/share/locale/en_US.UTF-8 "${WK_PATH}/usr/share/locale"/ + +# pipes-sh +echo "Installing pipes.sh..." +cp -a /usr/bin/tput "${WK_PATH}/usr/bin"/ + +# Timezones +if [[ ! -d "/var/db/timezone" ]]; then + echo "Installing timezones..." + rsync -aS /var/db/timezone "${WK_PATH}/var/db"/ +fi + +# zsh +echo "Installing zsh..." +cp -a /bin/zsh "${WK_PATH}/bin"/ +rsync -aS /usr/lib/zsh "${WK_PATH}/usr/lib"/ +rsync -aS /usr/share/zsh "${WK_PATH}/usr/share"/ +rsync -aS /usr/local/share/zsh "${WK_PATH}/usr/local/share"/ + +# Misc +cp -a aliases "${WK_PATH}/.aliases" +cp -a bashrc "${WK_PATH}/etc/profile" +cp -a vimrc "${WK_PATH}/.vimrc" +cp -a zshrc "${WK_PATH}/etc/zshenv" + +# WizardKit +echo "Installing WizardKit env..." +touch "${WK_PATH}/.wk-live-macos" +ln -s /Volumes/RAM_Disk/Logs "${WK_PATH}/var/root/Logs" +cp -a ../../images/macOS.png "${WK_PATH}/usr/local/wallpaper.png" +rsync -aS /usr/bin/{env,killall} "${WK_PATH}/usr/bin"/ +rsync -aS live-macos-startup ../../scripts/ "${WK_PATH}/usr/local/bin"/ + +# Convert to compressed read-only image +#echo "Converting to read-only image..." +#hdiutil convert -format UDZO -o "${OUT_NAME}.sparsebundle" "${OUT_NAME}.dmg" +# TODO diff --git a/setup/macos/vimrc b/setup/macos/vimrc new file mode 100644 index 00000000..6a4dc237 --- /dev/null +++ b/setup/macos/vimrc @@ -0,0 +1,81 @@ +" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just +" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime +" you can find below. If you wish to change any of those settings, you should +" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten +" everytime an upgrade of the vim packages is performed. It is recommended to +" make changes after sourcing debian.vim since it alters the value of the +" 'compatible' option. + +" This line should not be removed as it ensures that various options are +" properly set to work with the Vim-related packages available in Debian. +runtime! debian.vim + +" Uncomment the next line to make Vim more Vi-compatible +" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous +" options, so any other options should be set AFTER setting 'compatible'. +"set compatible + +" Vim5 and later versions support syntax highlighting. Uncommenting the next +" line enables syntax highlighting by default. +syntax on + +" If using a dark background within the editing area and syntax highlighting +" turn on this option as well +set background=dark + +" Uncomment the following to have Vim jump to the last position when +" reopening a file +"if has("autocmd") +" au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif +"endif + +" Uncomment the following to have Vim load indentation rules and plugins +" according to the detected filetype. +"if has("autocmd") +" filetype plugin indent on +"endif + +" The following are commented out as they cause vim to behave a lot +" differently from regular Vi. They are highly recommended though. +"set showcmd " Show (partial) command in status line. +set showmatch " Show matching brackets. +"set ignorecase " Do case insensitive matching +"set smartcase " Do smart case matching +"set incsearch " Incremental search +"set autowrite " Automatically save before commands like :next and :make +"set hidden " Hide buffers when they are abandoned +"set mouse=a " Enable mouse usage (all modes) + +" Source a global configuration file if available +if filereadable("/etc/vim/vimrc.local") + source /etc/vim/vimrc.local +endif + +" 2Shirt Stuff +set autoindent " align the new line indent with the previous line +set expandtab " insert spaces when hitting TABs +set nowrap " I'd rather manually wrap than manually unwrap +set shiftround " round indent to multiple of 'shiftwidth' +set shiftwidth=2 " operation >> indents 2 columns; << unindents 2 columns +set softtabstop=2 " insert/delete 2 spaces when hitting a TAB/BACKSPACE +set tabstop=2 " an hard TAB displays as 2 columns + +" Python Stuff. +au FileType python set textwidth=79 " lines longer than 79 columns will be broken +au FileType python call matchadd('ColorColumn', '\%80v') + +" Do wrap stuff +au FileType mail set wrap +au FileType text set wrap + +" Enable code folding +set foldmethod=indent +" Keep all folds open when a file is opened +augroup OpenAllFoldsOnFileOpen + autocmd! + autocmd BufRead * normal zR +augroup END + +" macOS stuff +set backspace=indent,eol,start +set ruler diff --git a/setup/macos/zshrc b/setup/macos/zshrc new file mode 100644 index 00000000..5e3d7fab --- /dev/null +++ b/setup/macos/zshrc @@ -0,0 +1,25 @@ +export HOME=/Volumes/RAM_Disk +export LC_ALL=en_US.UTF-8 +export LANG=en_US.UTF-8 +export EDITOR='vim' +export VISUAL='vim' +export PAGER='less' + +export XDG_CACHE_HOME="$HOME/.cache" +export XDG_CONFIG_DIRS="/etc/xdg" +export XDG_CONFIG_HOME="/" +export XDG_DATA_DIRS="/usr/local/share:/usr/share" +export XDG_DATA_HOME="$HOME/.local/share" + +# Ensure path arrays do not contain duplicates. +typeset -gU cdpath fpath mailpath path + +path=( + /usr/local/opt/{e2fsprogs,ruby,util-linux}/{bin,sbin} + /usr/local/{bin,sbin} + $path +) + +## Load aliases +. "/.aliases" +