Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automated method to install multiple packages? #3

Open
paulirish opened this issue Apr 23, 2012 · 14 comments
Open

automated method to install multiple packages? #3

paulirish opened this issue Apr 23, 2012 · 14 comments

Comments

@paulirish
Copy link

I love this sort of list; really nice job putting it together.

Once Package Control is in place, is there a nice way to bulk install all these packages? I ask because I'm putting together a larger framework and I'd like the install script to be able to set up the SublimeText packages on its own.

So ideally, you run my install script (let's assume its a shell script on os x, windows):

  • if ST2 is installed, install PackageControl if it's not there already.
  • once PC is in, install a list of these packages (or my own list)
  • you then open ST2 all the magic is there, waiting for you

Is this at all possible?

ping @wbond as he's the expert here.

@wbond
Copy link

wbond commented Apr 24, 2012

To install Package Control, http://sublime.wbond.net/Package%20Control.sublime-package needs to be placed inside of the Installed Packages/ folder. The next time Sublime starts, it will install the package.

To batch install other packages, a Package Control.sublime-settings file needs to be placed into the Packages/User/ folder. Inside of the settings file should be a JSON object with the key "installed_packages" that references a list of package names. When Package Control starts, if any of those packages are not present, the will be automatically downloaded and installed. Here is an example: http://pastebin.com/NLEavL1K.

@paulirish
Copy link
Author

Magic. Exactly what I needed to hear. :)

Thanks Will! Your contributions are incredible.

@mrmartineau
Copy link
Owner

@wbond, that is awesome! Perhaps I'll create that file here so people can bulk install all these packages.

@paulirish Could the Package Control.sublime-package file & other custom settings files be installed by running one install script? And @wbond Could Package Control & this install script be installed with one command & then you restart Sublime?

@wbond
Copy link

wbond commented Apr 25, 2012

It would be fairly trivial to write a bash script that utilizes wget/curl to perform the download and install on OS X and Linux. I'm sure there is some way to do the same on Windows with WSH, there is just the slight added complexity that the Windows versions of Sublime can be portable, so there isn't always a definitive place for the config folder.

@alister
Copy link

alister commented Apr 28, 2012

I've got a Puppet manifest to install the dev (or beta) and then, after the program has been run for the first time (and the base packages have been installed/directories created), it will go on to install whatever other packages you specify.

https://github.com/alister/puppet-sublimetext2

@mmacedo
Copy link

mmacedo commented Mar 29, 2013

@paulirish @wbond, it would be nice to have a oneliner like @mrmartineau suggested, but to be executed not from the editor, from command line. As you can see in the snippet below, I use curl to download package_control on Linux and cp to paste my package list, but after that I have to open, wait and close Sublime Text 2 manually several times for it complete. I don't think I can open sublime text 2 just to execute a script and close with a command.

ST2=~/.config/sublime-text-2
mkdir -p $ST2/{Installed\ Packages,Packages/User}
curl http://sublime.wbond.net/Package%20Control.sublime-package \
  > $ST2/Installed\ Packages/Package\ Control.sublime-package
cp $DOTFILES/st2/* $ST2/Packages/User
# Open Sublime Text and wait a bunch of minutes for package_control to install
# itself and all packages (several errors and manual restarts are expected)

@vishaltelangre
Copy link

@mmacedo I have wrote a little gist to make this process little easier:
https://gist.github.com/vishaltelangre/5075346

@mrmartineau
Copy link
Owner

Thanks @mmacedo. I will link to your post in the wiki

@evanplaice
Copy link

@mrmartineau @mmacedo @paulirish @wbond. Go figure...

I've been working on automating the sublime install+config. I started with a shell script then changed to python. A network admin buddy of mine is learning python so I decided to rewrite it as a python application and make it cross-platform so he can see the python-equivalent of a bash script.

Note: I haven't implemented the Windows portion yet but it should work in both Linux and OSX.

Since there's interest here, I migrated the code into its own repository @ https://github.com/evanplaice/sublime-text-seed.

The setup.py script handles the following:

  1. _Check and install Sublime Text_

    If Sublime Text isn't found, it automates the install via apt-get (*nix), homebrew (OSX), or chocolatey (Windows).

  2. _Install Package Control_

    Since Package Control needs to be installed separately, it fetches it with urllib2 via a GET request.

  3. _Copy the configuration_

    The config files found in the config directory are copied to the default settings locations, which differ for each OS.

  4. _Copy the license (Not Implemented)_

    If found , the license file is setup.

    Note: Which is included in .gitignore by default to prevent a credential leak.

@ghost
Copy link

ghost commented Aug 7, 2016

And in Powershell 5:

$packageControl = "http://sublime.wbond.net/Package%20Control.sublime-package"
$sublimeConfig = "$env:APPDATA\Sublime Text 3"
$packagesRoot = "$sublimeConfig\Installed Packages"
$userPackages = "$sublimeConfig\Packages\User"

Invoke-WebRequest $packageControl -OutFile "$packagesRoot\Package Control.sublime-package"

$packagesToInstall = @{
    installed_packages = @(
    "SFTP",
    "Git"
    )
}

ConvertTo-Json $packagesToInstall | Out-File "$userPackages\Package Control.sublime-settings" -Encoding ASCII

@ahmadassaf
Copy link

building on @evanplaice code .. i have also included automatic sublime projects creation in https://github.com/ahmadassaf/sublime-text-bootstrap

@wbond
Copy link

wbond commented Mar 9, 2017

@ahmadassaf @evanplaice The code you have is extremely insecure in terms of installing Package Control:

  1. Is uses HTTP, allowing MITM attacks
  2. It uses a domain name that Package Control stopped using years ago

Modern versions of Sublime Text include a command to install Package Control securely. If you want to automate things, just call that command (look in the Default.sublime-commands for the command name).

@ahmadassaf
Copy link

Thanks a lot @wbond for this info. I have just updated the link to the one i noticed in the latest instructions https://packagecontrol.io/Package%20Control.sublime-package

@evanplaice
Copy link

@wbond Thanks for the heads-up. The package control setup has been updated to use the more secure source link. Using the command pallet would be great but this tool is intended to be used as a complete unattended setup. AFAIK, it's not possible to launch commands in sublime directly from the CLI.

@ahmadassaf Nice work. When I get the chance I'll have to review the changes you made in detail, I could probably learn a few things from the improvements you made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants