sh 设置一台新Mac

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 设置一台新Mac相关的知识,希望对你有一定的参考价值。

#!/usr/bin/env bash

echo '------------'
echo 'Setting up iCloud drive link'
ln -s ~/Library/Mobile\ Documents/com~apple~CloudDocs/ ~/iCloud
echo '------------'
echo 'Setting up links to executables'

mkdir -p ~/bin
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl ~/bin/subl

cd ~/iCloud
stow -t ~/bin bin
cd -

echo '------------'
echo 'Setting up links to dotfiles'

ln -s ~/iCloud/dotfiles/.ssh ~/.
ln -s ~/iCloud/dotfiles/.subversion ~/.

cd ~/iCloud/dotfiles
stow -t ~/.config fish
stow -t ~ git
stow -t ~ hg
stow -t ~ neovim
stow -t ~ python
stow -t ~ slackcat
stow -t ~ tmux
stow -t ~ travis
# stow -t ~ vim
stow -t ~ z
# stow -t ~ zsh
cd -

echo '------------'
echo 'Setting up applications preferences'
cd ~/iCloud/Preferences
stow -t ~/Library/Preferences iterm
# stow -t ~/Library/Preferences magnet
stow -t ~/Library/Preferences sequel\ pro
cd -

cd ~/iCloud
stow -t ~/Library/Application\ Support Application\ Support
cd -
#!/usr/bin/env bash

VOL_NAME="Backup"
DIR="/Volumes/$VOL_NAME"

rsync  -av  $DIR/bin        $HOME
rsync  -av  $DIR/Developer  $HOME
rsync  -av  $DIR/Documents/{Books,PDR}  $HOME/Documents
rsync  -av  $DIR/Downloads  $HOME
rsync  -av  $DIR/Music      $HOME
rsync  -av  $DIR/Pictures   $HOME
#!/usr/bin/env bash

# Originally from https://mths.be/osx

# Ask for the administrator password upfront
sudo -v

# Keep-alive: update existing `sudo` time stamp until the script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

###############################################################################
# General UI/UX                                                               #
###############################################################################

# Set computer name (as done via System Preferences ? Sharing)
sudo scutil --set ComputerName "$1"
sudo scutil --set HostName "$1"
sudo scutil --set LocalHostName "$1"
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$1"

# Set standby delay to 24 hours (default is 1 hour or 3600)
#sudo pmset -a standbydelay 86400

# Disable the sound effects on boot
sudo nvram SystemAudioVolume=" "

# Set highlight color to green
defaults write NSGlobalDomain AppleAquaColorVariant -int 6

# Set sidebar icon size to medium
defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 2

# Expand save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true

# Expand print panel by default
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true

# Save to disk (not to iCloud) by default
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false

# Check for software updates daily, not just once per week
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1

# Disable Notification Center and remove the menu bar icon
launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist 2> /dev/null

# Disable smart quotes as theyÕre annoying when typing code
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false

# Disable smart dashes as theyÕre annoying when typing code
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false

# Set a custom wallpaper image. `DefaultDesktop.jpg` is already a symlink, and
# all wallpapers are in `/Library/Desktop Pictures/`. The default is `Wave.jpg`.
#rm -rf ~/Library/Application Support/Dock/desktoppicture.db
#sudo rm -rf /System/Library/CoreServices/DefaultDesktop.jpg
#sudo ln -s /path/to/your/image /System/Library/CoreServices/DefaultDesktop.jpg

###############################################################################
# SSD-specific tweaks                                                         #
# You might want to disable these if you are not running an SSD               #
###############################################################################

# Disable local Time Machine snapshots
sudo tmutil disablelocal

# Disable hibernation (speeds up entering sleep mode)
sudo pmset -a hibernatemode 0

# Remove the sleep image file to save disk space
sudo rm -f /private/var/vm/sleepimage
# Create a zero-byte file insteadÉ
sudo touch /private/var/vm/sleepimage
# Éand make sure it canÕt be rewritten
sudo chflags uchg /private/var/vm/sleepimage

# Disable the sudden motion sensor as itÕs not useful for SSDs
#sudo pmset -a sms 0

###############################################################################
# Trackpad, mouse, keyboard, Bluetooth accessories, and input                 #
###############################################################################

# Enable full keyboard access for all controls
# (e.g. enable Tab in modal dialogs)
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3

# Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 15

###############################################################################
# Screen                                                                      #
###############################################################################

# Require password immediately after sleep or screen saver begins
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0

# Save screenshots in subfolder in the desktop
mkdir ${HOME}/Desktop/Screenshots
defaults write com.apple.screencapture location -string "${HOME}/Desktop/Screenshots"

# Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF)
defaults write com.apple.screencapture type -string "png"

# Disable shadow in screenshots
defaults write com.apple.screencapture disable-shadow -bool true

# Enable subpixel font rendering on non-Apple LCDs
defaults write NSGlobalDomain AppleFontSmoothing -int 2

# Enable HiDPI display modes (requires restart)
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true

###############################################################################
# Finder                                                                      #
###############################################################################

# Finder: disable window animations and Get Info animations
defaults write com.apple.finder DisableAllAnimations -bool true

# Set Desktop as the default location for new Finder windows
# For other paths, use `PfLo` and `file:///full/path/here/`
defaults write com.apple.finder NewWindowTarget -string "PfLo"
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/"

# Show icons for hard drives, servers, and removable media on the desktop
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true

# Finder: show hidden files by default
defaults write com.apple.finder AppleShowAllFiles -bool true

# Finder: show all filename extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool true

# Finder: show status bar
defaults write com.apple.finder ShowStatusBar -bool true

# Finder: show path bar
defaults write com.apple.finder ShowPathbar -bool true

# Finder: allow text selection in Quick Look
defaults write com.apple.finder QLEnableTextSelection -bool true

# Display full POSIX path as Finder window title
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true

# When performing a search, search the current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"

# Disable the warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false

# Enable spring loading for directories
defaults write NSGlobalDomain com.apple.springing.enabled -bool true

# Tweak the spring loading delay for directories
defaults write NSGlobalDomain com.apple.springing.delay -float .5

# Avoid creating .DS_Store files on network volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

# Automatically open a new Finder window when a volume is mounted
defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true
defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true
defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true

# Show item info near icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist

# Show item info at the bottom of the icons on the desktop
/usr/libexec/PlistBuddy -c "Set DesktopViewSettings:IconViewSettings:labelOnBottom true" ~/Library/Preferences/com.apple.finder.plist

# Enable snap-to-grid for icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist

# Set grid spacing for icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:gridSpacing 50" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:gridSpacing 50" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:gridSpacing 50" ~/Library/Preferences/com.apple.finder.plist

# Set the size of icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:iconSize 52" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:iconSize 52" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:iconSize 52" ~/Library/Preferences/com.apple.finder.plist

# Use list view in all Finder windows by default
# Four-letter codes for the other view modes: `icnv`, `clmv`, `Flwv`
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"

# Disable the warning before emptying the Trash
# defaults write com.apple.finder WarnOnEmptyTrash -bool false

# Empty Trash securely by default
defaults write com.apple.finder EmptyTrashSecurely -bool true

# Show the ~/Library folder
chflags nohidden ~/Library

# Expand the following File Info panes:
# ÒGeneralÓ, ÒOpen withÓ, and ÒSharing & PermissionsÓ
defaults write com.apple.finder FXInfoPanesExpanded -dict \
    General -bool true \
    OpenWith -bool true \
    Privileges -bool true

###############################################################################
# Dock, Dashboard, and hot corners                                            #
###############################################################################

# Enable highlight hover effect for the grid view of a stack (Dock)
defaults write com.apple.dock mouse-over-hilite-stack -bool true

# Set the icon size of Dock items to 36 pixels
defaults write com.apple.dock tilesize -int 48

# Change minimize/maximize window effect
defaults write com.apple.dock mineffect -string "scale"

# Minimize windows into their applicationÕs icon
defaults write com.apple.dock minimize-to-application -bool true

# Show indicator lights for open applications in the Dock
defaults write com.apple.dock show-process-indicators -bool true

# Don't animate opening applications from the Dock
defaults write com.apple.dock launchanim -bool false

# Speed up Mission Control animations
defaults write com.apple.dock expose-animation-duration -float 0.1

# Disable Dashboard
defaults write com.apple.dashboard mcx-disabled -bool true

# Don't show Dashboard as a Space
defaults write com.apple.dock dashboard-in-overlay -bool true

# Don't automatically rearrange Spaces based on most recent use
defaults write com.apple.dock mru-spaces -bool false

# Remove the auto-hiding Dock delay
defaults write com.apple.dock autohide-delay -float 0
# Remove the animation when hiding/showing the Dock
defaults write com.apple.dock autohide-time-modifier -float 0

# Automatically hide and show the Dock
defaults write com.apple.dock autohide -bool true

# Make Dock icons of hidden applications translucent
defaults write com.apple.dock showhidden -bool true

###############################################################################
# Safari & WebKit                                                             #
###############################################################################

# Privacy: donÕt send search queries to Apple
defaults write com.apple.Safari UniversalSearchEnabled -bool false
defaults write com.apple.Safari SuppressSearchSuggestions -bool true

# Press Tab to highlight each item on a web page
defaults write com.apple.Safari WebKitTabToLinksPreferenceKey -bool true
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2TabsToLinks -bool true

# Set SafariÕs home page to `about:blank` for faster loading
defaults write com.apple.Safari HomePage -string "about:blank"

# Prevent Safari from opening ÔsafeÕ files automatically after downloading
defaults write com.apple.Safari AutoOpenSafeDownloads -bool false

# Allow hitting the Backspace key to go to the previous page in history
#defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true

# Hide SafariÕs bookmarks bar by default
defaults write com.apple.Safari ShowFavoritesBar -bool false

# Hide SafariÕs sidebar in Top Sites
defaults write com.apple.Safari ShowSidebarInTopSites -bool false

# Enable SafariÕs debug menu
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true

# Make SafariÕs search banners default to Contains instead of Starts With
defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false

# Remove useless icons from SafariÕs bookmarks bar
defaults write com.apple.Safari ProxiesInBookmarksBar "()"

# Enable the Develop menu and the Web Inspector in Safari
defaults write com.apple.Safari IncludeDevelopMenu -bool true
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true

# Add a context menu item for showing the Web Inspector in web views
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true

###############################################################################
# Spotlight                                                                   #
###############################################################################

# Hide Spotlight tray-icon (and subsequent helper)
#sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search
# Disable Spotlight indexing for any volume that gets mounted and has not yet
# been indexed before.
# Use `sudo mdutil -i off "/Volumes/foo"` to stop indexing any volume.
sudo defaults write /.Spotlight-V100/VolumeConfiguration Exclusions -array "/Volumes"
# Change indexing order and disable some search results
# Yosemite-specific search results (remove them if your are using OS X 10.9 or older):
#   MENU_DEFINITION
#   MENU_CONVERSION
#   MENU_EXPRESSION
#   MENU_SPOTLIGHT_SUGGESTIONS (send search queries to Apple)
#   MENU_WEBSEARCH             (send search queries to Apple)
#   MENU_OTHER
defaults write com.apple.spotlight orderedItems -array \
    '{"enabled" = 1;"name" = "APPLICATIONS";}' \
    '{"enabled" = 1;"name" = "SYSTEM_PREFS";}' \
    '{"enabled" = 1;"name" = "DIRECTORIES";}' \
    '{"enabled" = 1;"name" = "PDF";}' \
    '{"enabled" = 1;"name" = "FONTS";}' \
    '{"enabled" = 0;"name" = "DOCUMENTS";}' \
    '{"enabled" = 0;"name" = "MESSAGES";}' \
    '{"enabled" = 0;"name" = "CONTACT";}' \
    '{"enabled" = 0;"name" = "EVENT_TODO";}' \
    '{"enabled" = 0;"name" = "IMAGES";}' \
    '{"enabled" = 0;"name" = "BOOKMARKS";}' \
    '{"enabled" = 0;"name" = "MUSIC";}' \
    '{"enabled" = 0;"name" = "MOVIES";}' \
    '{"enabled" = 0;"name" = "PRESENTATIONS";}' \
    '{"enabled" = 0;"name" = "SPREADSHEETS";}' \
    '{"enabled" = 0;"name" = "SOURCE";}' \
    '{"enabled" = 0;"name" = "MENU_DEFINITION";}' \
    '{"enabled" = 0;"name" = "MENU_OTHER";}' \
    '{"enabled" = 0;"name" = "MENU_CONVERSION";}' \
    '{"enabled" = 0;"name" = "MENU_EXPRESSION";}' \
    '{"enabled" = 0;"name" = "MENU_WEBSEARCH";}' \
    '{"enabled" = 0;"name" = "MENU_SPOTLIGHT_SUGGESTIONS";}'
# Load new settings before rebuilding the index
killall mds > /dev/null 2>&1
# Make sure indexing is enabled for the main volume
sudo mdutil -i on / > /dev/null
# Rebuild the index from scratch
sudo mdutil -E / > /dev/null

###############################################################################
# Terminal & iTerm 2                                                          #
###############################################################################

# Only use UTF-8 in Terminal.app
defaults write com.apple.terminal StringEncodings -array 4

###############################################################################
# Time Machine                                                                #
###############################################################################

# Prevent Time Machine from prompting to use new hard drives as backup volume
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true

# Disable local Time Machine backups
# hash tmutil &> /dev/null && sudo tmutil disablelocal

###############################################################################
# Activity Monitor                                                            #
###############################################################################

# Show the main window when launching Activity Monitor
defaults write com.apple.ActivityMonitor OpenMainWindow -bool true

# Visualize CPU usage in the Activity Monitor Dock icon
defaults write com.apple.ActivityMonitor IconType -int 5

# Show all processes in Activity Monitor
defaults write com.apple.ActivityMonitor ShowCategory -int 0

# Sort Activity Monitor results by CPU usage
defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage"
defaults write com.apple.ActivityMonitor SortDirection -int 0

###############################################################################
# Address Book, Dashboard, iCal, TextEdit, and Disk Utility                   #
###############################################################################

# Enable the debug menu in Address Book
defaults write com.apple.addressbook ABShowDebugMenu -bool true

# Enable Dashboard dev mode (allows keeping widgets on the desktop)
defaults write com.apple.dashboard devmode -bool true

# Enable the debug menu in iCal (pre-10.8)
defaults write com.apple.iCal IncludeDebugMenu -bool true

# Use plain text mode for new TextEdit documents
defaults write com.apple.TextEdit RichText -int 0
# Open and save files as UTF-8 in TextEdit
defaults write com.apple.TextEdit PlainTextEncoding -int 4
defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4
# Set tab width to 4 instead of the default 8
defaults write com.apple.TextEdit "TabWidth" '4'

# Enable the debug menu in Disk Utility
defaults write com.apple.DiskUtility DUDebugMenuEnabled -bool true
defaults write com.apple.DiskUtility advanced-image-options -bool true

###############################################################################
# Mac App Store                                                               #
###############################################################################

# Enable the WebKit Developer Tools in the Mac App Store
defaults write com.apple.appstore WebKitDeveloperExtras -bool true

# Enable Debug Menu in the Mac App Store
defaults write com.apple.appstore ShowDebugMenu -bool true
#!/usr/bin/env bash

if [ -z ${1} ]
then
    echo 'hostname not set'
    exit;
fi

# Ask for the administrator password upfront
sudo -v

# Keep-alive: update existing `sudo` time stamp until the script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

echo 'Updating macOS'
sudo softwareupdate -iva

echo '------------'
echo 'Xcode tools'
xcode-select --install

echo '------------'
echo 'Installing software'

echo 'Homebrew'
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew install ack
brew install ansible
# brew install antigen
brew install curl
brew install exa
brew install fish
brew install fzf
brew install git
brew install htop-osx
brew install httpie
brew install imagemagick
brew install keychain
brew install libyaml
brew install node
brew install python3
brew install reattach-to-user-namespace
brew install ruby
brew install slackcat
brew install stow
brew install the_silver_searcher
brew install tidy-html5
brew install tmux
# brew install vim --with-lua --with-python3
brew install wget
brew install z
# brew install zsh
brew install neovim

echo '------------'
echo 'Homebrew: taps'
brew tap caskroom/cask
brew tap caskroom/fonts
brew tap caskroom/drivers
brew tap buo/cask-upgrade
brew tap homebrew/homebrew-php

echo '------------'
echo 'Homebrew: casks'
brew tap caskroom/cask
brew cask install aerial
brew cask install appcleaner
brew cask install boom
brew cask install firefox
brew cask install flux
brew cask install flycut
brew cask install iterm2
brew cask install java
brew cask install magnet
brew cask install microsoft-office
brew cask install oversight
brew cask install sequel-pro
brew cask install slack
brew cask install spotify
brew cask install sublime-text
brew cask install the-unarchiver
brew cask install tunnelbear
brew cask install vagrant
brew cask install vimr
brew cask install virtualbox

echo '------------'
echo 'Hombrew: cask upgrade'
brew cu

echo '------------'
echo 'Homebrew: fonts'
brew cask install font-hack-nerd-font-mono
brew cask install font-monoid-nerd-font-mono

echo '------------'
echo 'Homebre: drivers'
brew cask install caldigit-usb-c-dock-driver

echo '------------'
echo 'Homebre: php'
brew install homebrew/php/php72
brew install homebrew/php/php72-cntl
brew install homebrew/php/php72-msgpack

brew cleanup
brew cask cleanup

echo '------------'
echo 'Python'
pip install --upgrade pip
pip install autopep8
pip install flake8
pip install isort
pip install keyring
pip install mercurial
pip install mercurial-keyring
pip install neovim
pip install pycodestyle
pip install pyaml
pip install pyflakes
pip install pyyaml
pip install virtualenv
pip install virtualenvwrapper
pip install virtualfish

echo '------------'
echo 'Ruby'
gem install bundler
gem install rubocop
gem install travis

echo '------------'
echo 'Node'
npm -g install bower
npm -g install jshint
# https://github.com/jlongster/prettier/
npm -g install prettier
# npm -g install requirejs

echo '------------'
echo 'Vim'
# curl http://j.mp/spf13-vim3 -L -o - | sh
curl -sLf https://spacevim.org/install.sh | bash

echo '------------'
echo 'Setting up iCloud drive link'
ln -s ~/Library/Mobile\ Documents/com~apple~CloudDocs/ ~/iCloud
echo '------------'
echo 'Setting up links to executables'

mkdir -p ~/bin
ln -s /Applications/Sublime Text.app/Contents/SharedSupport/bin/subl ~/bin/subl

cd ~/iCloud
stow -t ~/bin bin
cd -

echo '------------'
echo 'Setting up links to dotfiles'

ln -s ~/iCloud/dotfiles/.ssh ~/.
ln -s ~/iCloud/dotfiles/.subversion ~/.

cd ~/iCloud/dotfiles
stow -t ~/.config fish
stow -t ~ git
stow -t ~ hg
stow -t ~ neovim
stow -t ~ python
stow -t ~ slackcat
stow -t ~ tmux
stow -t ~ travis
# stow -t ~ vim
stow -t ~ z
# stow -t ~ zsh
cd -

echo '------------'
echo 'Setting up applications preferences'
cd ~/iCloud/Preferences
stow -t ~/Library/Preferences iterm
stow -t ~/Library/Preferences magnet
stow -t ~/Library/Preferences sequel\ pro
cd -

cd ~/iCloud
stow -t ~/Library/Application\ Support Application\ Support
cd -

echo '------------'
echo 'Setting up macOS preferences'

./03_preferences.sh $1

killall Finder
killall Dock

# Shell
echo '------------'
echo 'Setting up fish shell'
echo '/usr/local/bin/fish' | sudo tee -a /etc/shells
chsh -s $(which fish)
curl -L https://get.oh-my.fish | fish
omf install

# fzf
(brew --prefix)/opt/fzf/install

echo 'Done. Note that some of these changes require a logout/restart of your OS to take effect.'
#!/usr/bin/env bash

VOL_NAME="Backup"
DIR="/Volumes/$VOL_NAME"

if [ ! -d "$DIR" ]; then
    diskutil apfs addVolume disk1 APFS $VOL_NAME
fi

rsync  -av  ~/bin        $DIR
rsync  -av  ~/Developer  $DIR
rsync  -av  ~/Documents  $DIR
rsync  -av  ~/Downloads  $DIR
rsync  -av  ~/iCloud     $DIR
rsync  -av  ~/Library    $DIR
rsync  -av  ~/Music      $DIR
rsync  -av  ~/Pictures   $DIR

以上是关于sh 设置一台新Mac的主要内容,如果未能解决你的问题,请参考以下文章

买了一台新IBM服务器,怎么进入阵列卡配置界面?webBIOS

vmware新建一台新的虚拟机

在 Mac 上构建 MAMP 环境...最佳解决方案?

买了一台新IBM服务器,怎么进入阵列卡配置界面?webBIOS

一台新电脑从零搭建iOS开发环境

一台新电脑从零搭建iOS开发环境