Skip to content

Instantly share code, notes, and snippets.

@hwrdprkns
Last active August 29, 2015 14:04
Show Gist options
  • Save hwrdprkns/091035baacd35135c709 to your computer and use it in GitHub Desktop.
Save hwrdprkns/091035baacd35135c709 to your computer and use it in GitHub Desktop.
Python script to backup all your brew files and an example of the output.
class Command(object):
"""
Run a command and capture it's output string, error string and exit status
Source: http://stackoverflow.com/a/13848259/354247
"""
def __init__(self, command):
self.command = command
def run(self, shell=True):
import subprocess as sp
process = sp.Popen(self.command, shell = shell, stdout = sp.PIPE, stderr = sp.PIPE)
self.pid = process.pid
self.output, self.error = process.communicate()
self.failed = process.returncode
return self
@property
def returncode(self):
return self.failed
homebrew_packages = Command('brew list').run().output.split()
cask_packages = Command('brew cask list').run().output.split()
brew = ''.join(['install %s \n' % item for item in homebrew_packages])
cask = ''.join(['cask install %s \n' % item for item in cask_packages])
file_output = """
cleanup
update
upgrade
# Install the normal packages
%s
# Now install our cask stuff
install caskroom/cask/brew-cask
%s
cleanup""" % (brew, cask)
print file_output
cleanup
update
upgrade
# Install the normal packages
install a52dec
install ack
install aften
install android-ndk
install android-sdk
install ant
install astyle
install atk
install autoconf
install autojump
install automake
install bash-completion
install bison
install boost
install brew-cask
install cairo
install cassandra
install cmake
install coreutils
install cscope
install curl
install dex2jar
install dos2unix
install doxygen
install ec2-api-tools
install faac
install faad2
install fcrackzip
install fontconfig
install freetype
install gdbm
install gdk-pixbuf
install gettext
install gist
install git
install git-extras
install glib
install gnupg
install gobject-introspection
install gradle
install grc
install gtk+
install gtksourceview
install harfbuzz
install highlight
install icu4c
install imagemagick
install intltool
install jasper
install jpeg
install jq
install lame
install libdca
install libevent
install libffi
install libgpg-error
install libksba
install libmemcached
install libogg
install libpng
install librsync
install libtiff
install libtool
install libvorbis
install libvpx
install libxml2
install libxslt
install libyaml
install little-cms
install lua
install macvim
install mad
install makedepend
install maven
install meld
install memcached
install mercurial
install multimarkdown
install mysql
install node
install opencore-amr
install openssl
install ossp-uuid
install pango
install pcre
install phantomjs
install pixman
install pkg-config
install pngquant
install popt
install postgresql
install py2cairo
install pygobject
install pygtk
install pygtksourceview
install python
install python3
install qt
install rarian
install rbenv
install readline
install reattach-to-user-namespace
install ruby-build
install spark
install spdylay
install sqlite
install the_silver_searcher
install vim
install watchman
install wget
install x264
install xvid
install xz
install yasm
# Now install our cask stuff
install caskroom/cask/brew-cask
cask install alfred
cask install android-file-transfer
cask install appcleaner
cask install atom
cask install caffeine
cask install ccleaner
cask install charles
cask install cloud
cask install dash
cask install diffmerge
cask install dropbox
cask install evernote
cask install filezilla
cask install firefox
cask install flux
cask install genymotion
cask install google-chrome
cask install handbrake
cask install intellij-idea-ce
cask install iterm2
cask install kindle
cask install macvim
cask install onepassword
cask install pycharm
cask install rdio
cask install skype
cask install sopcast
cask install spectacle
cask install spotify
cask install sublime-text3
cask install textmate
cask install the-unarchiver
cask install utorrent
cask install vagrant
cask install virtualbox
cask install vlc
cleanup
@hwrdprkns
Copy link
Author

Depends on OSX python, but also installs python with brew.

Just in case, but I don't think I'll ever want to do this...

# Specify your defaults in this environment variable
export HOMEBREW_CASK_OPTS="--appdir=/Applications --caskroom=/etc/Caskroom"

@hwrdprkns
Copy link
Author

Now that this is deprecated you might want to have a look at https://github.com/Homebrew/homebrew-brewdler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment