Skip to content

Instantly share code, notes, and snippets.

@koljonen
Created September 22, 2016 23:33
Show Gist options
  • Save koljonen/ccfa7e691edc997bbf4d269155aadc7f to your computer and use it in GitHub Desktop.
Save koljonen/ccfa7e691edc997bbf4d269155aadc7f to your computer and use it in GitHub Desktop.
pgcliSublime setup
if [ ! -f "`which brew`" ]; then
echo 'Setting up homebrew ...';
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
if [ ! -d ~/"Library/Application Support/Sublime Text 3/Packages" ]; then
echo 'Setting up Sublime ...';
brew install caskroom/cask/brew-cask
brew tap caskroom/versions
brew cask install sublime-text3
fi
if [ ! -f "`which pyenv`" ]; then
echo 'Setting up pyenv ...'
brew install pyenv
pyenv install 3.3.6
fi
echo 'Setting up pgcli'
~/.pyenv/versions/3.3.6/bin/pip3.3 install pgcli
cd ~/"Library/Application Support/Sublime Text 3/Installed Packages"
curl --output "Package Control.sublime-package" https://sublime.wbond.net/Package%20Control.sublime-package
echo 'Setting up pgclisublime ...'
cd ~/"Library/Application Support/Sublime Text 3/Packages"
git clone -b live https://github.com/koljonen/PgcliSublime.git
echo 'Setting up schema_hacker Sublime plugin ...'
git clone https://github.com/koljonen/schema_hacker.git
cat ~/"Library/Application Support/Sublime Text 3/Packages/PgcliSublime/PgcliSublime.sublime_settings" |
sed -E "s/(\"pgcli_dirs\":[[:space:]]+)\[\]/\1\[\"\/Users\/$USER\/.pyenv\/versions\/3.3.6\/bin\/\"\]/" |
sed -E "s/(\"pgcli_site_dirs\":[[:space:]]+)\[\]/\1\[\"\/Users\/$USER\/.pyenv\/versions\/3.3.6\/lib\/python3.3\/site-packages\/\"\]/" |
sed -E "s/(\"autocomplete_exclusions\":[[:space:]]+)\[\]/\1\[\".*\\\\\\\\\/index\\\\\\\\.sql\"\]/" |
sed -E "s/(\"casing_file\":[[:space:]]+)\"\"/\1\"\/Users\/$USER\/.config\/pgcli\/casing\"/" |
sed -E "s/(\"generate_casing_file\":[[:space:]]+)false/\1true/" > ~/"Library/Application Support/Sublime Text 3/Packages/User/PgcliSublime.sublime_settings"
sed -i.bak 's/generate_casing_file = False/generate_casing_file = True/' ~/.config/pgcli/config
rm ~/.config/pgcli/config.bak
echo 'Starting pgcli ...'
echo 'Please wait for it to finish "Refreshing completions..." before you quit (ctrl-D)'
~/.pyenv/versions/3.3.6/bin/pgcli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment