sh 通过Dropbox在Mac之间同步Homebrew安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 通过Dropbox在Mac之间同步Homebrew安装相关的知识,希望对你有一定的参考价值。
#!/bin/bash
# Sync Homebrew installations between Macs via Dropbox
#
BREW="/usr/local/bin/brew"
# first get local settings
echo "Reading local settings ..."
rm -f /tmp/brew-sync.*
$BREW tap > /tmp/brew-sync.taps
$BREW list > /tmp/brew-sync.installed
$BREW cask list -1 > /tmp/brew-sync.casks
# then combine it with list in Dropbox
echo "Reading settings from Dropbox ..."
[ -e ~/Dropbox/Apps/Homebrew/brew-sync.taps ] && cat ~/Dropbox/Apps/Homebrew/brew-sync.taps >> /tmp/brew-sync.taps
[ -e ~/Dropbox/Apps/Homebrew/brew-sync.installed ] && cat ~/Dropbox/Apps/Homebrew/brew-sync.installed >> /tmp/brew-sync.installed
[ -e ~/Dropbox/Apps/Homebrew/brew-sync.casks ] && cat ~/Dropbox/Apps/Homebrew/brew-sync.casks >> /tmp/brew-sync.casks
# make the lists unique and sync into Dropbox
echo "Syncing to Dropbox ..."
mkdir -p ~/Dropbox/Apps/Homebrew
cat /tmp/brew-sync.taps | sort | uniq > ~/Dropbox/Apps/Homebrew/brew-sync.taps
cat /tmp/brew-sync.installed | sort | uniq > ~/Dropbox/Apps/Homebrew/brew-sync.installed
cat /tmp/brew-sync.casks | sort | uniq > ~/Dropbox/Apps/Homebrew/brew-sync.casks
# Set taps
echo "Enabling taps ..."
for TAP in `cat ~/Dropbox/Apps/Homebrew/brew-sync.taps`; do
$BREW tap ${TAP} >/dev/null
done
# Install missing Homebrew packages
echo "Install missing packages ..."
for PACKAGE in `cat ~/Dropbox/Apps/Homebrew/brew-sync.installed`; do
$BREW list ${PACKAGE} >/dev/null
[ "$?" != "0" ] && $BREW install ${PACKAGE}
done
echo "Install missing casks ..."
for CASK in `cat ~/Dropbox/Apps/Homebrew/brew-sync.casks`; do
$BREW cask list -1 ${CASK} >/dev/null
[ "$?" != "0" ] && $BREW cask install ${CASK}
done
以上是关于sh 通过Dropbox在Mac之间同步Homebrew安装的主要内容,如果未能解决你的问题,请参考以下文章
sh 笔记:利用Dropbox在不同Mac之间同步Sublime Text 3设置 - 1。
sh 通过Dropbox保持你的@ohmyzsh~ / .zshrc同步
Dropbox for Mac(网络共享工具)
sh 同步Starbound保存到Dropbox
sh 快速克隆Sublime(3)设置为Dropbox上的ZIP(同步)
在 Windows 和 Mac OS X 之间共享 Dropbox 上的 Eclipse 目录