/clean-install

Personal reinstall/reconfig OSX

Primary LanguageShell

Table of contents

  1. Backup
    1. Data
    2. Configurations
  2. Restore
    1. Applications
    2. CLI
    3. Misc
  3. Scripts

Backup

data

Folders

~/Desktop ~/Documents ~/Downloads ~/Movies ~/Music ~/Pictures ~/Work

cp -v -R ~/Desktop ~/Documents ~/Downloads ~/Movies ~/Music ~/Pictures ~/Work /Volumes/Time\ Machine

Installed applications list

ls -1 /Applications | sed -e 's/\..*$//' > ~/Dropbox/Apps/apps-list.txt

npm Global packages

# list npm global packages | regex match only packages name | save into npm.txt
npm -g list --depth 0 | xp -o '([a-zA-Z@_/-]+)(?=@)' > ~/Dropbox/Apps/npm/npm-packages-list.txt

Yarn Global packages

cp $(yarn global dir)/package.json ~/Dropbox/Apps/npm/ && mv ~/Dropbox/Apps/npm/package.json ~/Dropbox/Apps/npm/yarn-package.json

brew packages

brew bundle dump
cp ~/Brewfile ~/Dropbox/Apps/Homebrew/

Thunderbird

  1. Connect a device for data transfer, either a local one such as a USB flash drive, or a remote storage drive.
  2. Open the Help menu and select Troubleshooting Information.
  3. Locate the "Profile Folder" entry, then click Show in Finder. Your Thunderbird profile folder will open in Finder.
  4. Quit Thunderbird.
  5. From your Thunderbird profile folder in Finder, open the Go menu and select Enclosing Folder two times.
  6. Hold down the control key while you click on the Thunderbird folder and select Copy "Thunderbird".
  7. Hold down the control key while you click the device you are using to transfer your data, then select Paste Item.
  8. If you are using a local transfer device, remove it safely from the source computer.

Source: https://support.mozilla.org/en-US/kb/moving-thunderbird-data-to-a-new-computer

Configurations

iTerm2

Preferences > Profiles > Colors > Colors Presets > Export... ~/Dropbox/Apps/iTerm2/iterm2-dracula-pref.itermcolors

zsh

cp ~/.zshrc ~/Dropbox/Apps/zsh

git

cp ~/.gitconfig ~/Dropbox/Apps/git

uBlock origin

Backup settings to ~/Dropbox/Apps/ublock/my-ublock-backup.txt

Tunnelblick

Export all configurations and settings on a computer by clicking the "Export Tunnelblick Setup" on the "Utilities" panel of Tunnelblick's "VPN Details" window.

Important: Saved usernames and passwords are not exported.

Tunnelblick will create a compressed ".tar.gz" file on your Desktop named "Tunnelblick Setup" followed by the date and time. The file can be expanded into a Tunnelblick Setup file (with ".tar.gz" changed to ".tblkSetup") by double-clicking it. (A compressed file is created because it is much smaller than the uncompressed version.)

Source: https://tunnelblick.net/cExportingAndImportingTunnelblickSetups.html

Plus, export username and password from Keychain

Carbon Copy Cleaner

If you wish to migrate your tasks from CCC on one system to CCC on another system, follow these steps:

Choose Export All Tasks from CCC's Task menu. Specify a name for the exported settings file and a location where to save it. Transfer the exported settings file to another Mac. Install CCC onto the other Mac Double-click the exported settings file. As prompted, review the task settings and reset the source/destination selections as necessary.

Source: https://bombich.com/kb/ccc6/migrating-ccc-tasks-from-one-system-another

Restore

Reinstall macOs

Create bootable usb

sudo /Applications/Install\ macOS\ Mojave.app/Contents/Resources/createinstallmedia --volume /Volumes/UNTITLED && echo Mojave Drive Created

Format disk and create coreStorage container (Fusion Drive)

Format Disk

diskutil list

if coreStorage exists :

diskutil coreStorage delete lvgUUID
diskutil list
diskutil coreStorage create "Fusion Drive" /dev/disk0 /dev/disk1
diskutil coreStorage createVolume lvgUUID jhfs+ "Macintosh" 100%
sudo /Applications/Install\ macOS\ Mojave.app/Contents/Resources/createinstallmedia --volume /Volumes/UNTITLED && echo Mojave Drive Created

Applications

Manually install applications

~/Dropbox/Apps/apps-list.txt

Finder

Show Path Bar

view > show path bar

iTerm2

# delete default settings and sync from dropbox
sudo rm ~/Library/Preferences/com.googlecode.iterm2.plist
sudo ln -s ~/Dropbox/Apps/iTerm2/com.googlecode.iterm2.plist ~/Library/Preferences

Cyberduck

ln -s /Users/hatem/Library/CloudStorage/Dropbox/Apps/cyberduck/Transfers /Users/hatem/Library/Group\ Containers/G69SCX94XU.duck/Library/Application\ Support/duck/Transfers
ln -s /Users/hatem/Library/CloudStorage/Dropbox/Apps/cyberduck/Sessions /Users/hatem/Library/Group\ Containers/G69SCX94XU.duck/Library/Application\ Support/duck/Sessions
ln -s /Users/hatem/Library/CloudStorage/Dropbox/Apps/cyberduck/History /Users/hatem/Library/Group\ Containers/G69SCX94XU.duck/Library/Application\ Support/duck/History
ln -s /Users/hatem/Library/CloudStorage/Dropbox/Apps/cyberduck/Bookmarks /Users/hatem/Library/Group\ Containers/G69SCX94XU.duck/Library/Application\ Support/duck/Bookmarks

Source: https://docs.cyberduck.io/cyberduck/faq/#preferences-and-application-support-files-location

Spectacles

# delete default settings and sync from dropbox
sudo rm ~/Library/Application\ Support/Spectacle/Shortcuts.json
sudo ln -s ~/Dropbox/Apps/Spectacle/Shortcuts.json ~/Library/Application\ Support/Spectacle/

Sketch

# delete default settings and sync from dropbox
sudo rm ~/Library/Preferences/com.bohemiancoding.sketch3.plist
sudo ln -s ~/Dropbox/Apps/Sketch/com.bohemiancoding.sketch3.plist ~/Library/Preferences
# delete default plugins folder and sync from dropbox
sudo rm -r ~/Library/Application\ Support/com.bohemiancoding.sketch3/Plugins
sudo ln -s ~/Dropbox/Apps/sketch/Plugins ~/Library/Application\ Support/com.bohemiancoding.sketch3

Transmission

# delete default settings and sync from dropbox
sudo rm ~/Library/Preferences/org.m0k.transmission.plist
sudo ln -s ~/Dropbox/Apps/Transmission/org.m0k.transmission.plist ~/Library/Preferences

uBlock origin

Restore saved settings from ~/Dropbox/Apps/ublock/my-ublock-backup.txt

CLI

Command line tools

xcode-select --install

Finder

# show hidden files
defaults write com.apple.finder AppleShowAllFiles YES
# remove hidding dock animation delay
defaults write com.apple.dock autohide-delay -float 0
defaults write com.apple.dock autohide-time-modifier -float 0.4; killall Dock

iTerm2

# restore zsh settings
cp ~/Dropbox/Apps/zsh/.zshrc ~
# install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# install bullet train theme
wget https://raw.githubusercontent.com/caiogondim/bullet-train-oh-my-zsh-theme/master/bullet-train.zsh-theme -P $ZSH_CUSTOM/themes/

Preferences > Profiles > Colors > Colors Presets > Import... ~/Dropbox/Apps/iTerm2/iterm2-dracula-pref.itermcolors

brew

# install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# restore brew packages
cp ~/Dropbox/Apps/Homebrew/ ~
brew bundle

git

# restore git settings
cp ~/Dropbox/Apps/git/.gitconfig ~

npm

install npm global packages

echo "Giving access to npm..."
sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config
echo "Install npm global packages ..."
cat ~/Dropbox/Apps/npm/npm-packages-list.txt | xargs npm install -g

yarn

npx yarn-global-restore ~/Dropbox/Apps/npm/yarn-package.json --keep-versions

Misc

curl https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts | sudo tee -a /etc/hosts

Scripts