mrmartineau / SublimeTextSetupWiki

Enable people to get started with Sublime Text 2 much more quickly
464 stars 33 forks source link

automated method to install multiple packages? #3

Open paulirish opened 12 years ago

paulirish commented 12 years ago

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):

Is this at all possible?

ping @wbond as he's the expert here.

wbond commented 12 years ago

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 _"installedpackages" 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 commented 12 years ago

Magic. Exactly what I needed to hear. :)

Thanks Will! Your contributions are incredible.

mrmartineau commented 12 years ago

@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 commented 12 years ago

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 commented 12 years ago

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 commented 11 years ago

@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 commented 11 years ago

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

mrmartineau commented 11 years ago

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

evanplaice commented 8 years ago

@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 commented 8 years ago

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 commented 7 years ago

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

wbond commented 7 years ago

@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 commented 7 years ago

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 commented 7 years ago

@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.