Sublime Forum

Installing Packages From The Command Line


I would like to be able to have my custom installation of Sublime Text be scriptable, so when I have to work on different machines I can install it and bring it up to speed in no time.

I’m already saving the config in my dotfiles, but the installation of Package Controll and packages themselves is a manual step everytime.

If you’re like me and have to work in different machines, or need to format your computer quite often, this gets really old over time.

So my suggestion would be to have a command in the CLI that would allow to install packages from a script.

An example of my configuration with VSCodium:

set -e

yay -S vscodium --noconfirm

# Utilities / syntax highlighting
codium --install-extension syler.sass-indented --force || :
codium --install-extension johnpapa.vscode-peacock --force || :

# JS
codium --install-extension dbaeumer.vscode-eslint --force || :

# etcetera

And then, with my dotfiles, symlink the config and upon first boot of the application I see my themes, my extensions and everything I need to start working.

With vim I can have a similarly easy script.

So to recap, the suggestion is to be able to install packages from the command line.

Does this make sense for anyone else? :slight_smile:

1 Like


As some kind of workaround you could git clone most of the packages in the ST packages directory.

But doesn’t Package Control install the plugins automatically according the settings files after it (itself) was installed? Thought it’d do so but not sure.



Uhm… Yes, I see that there is a installed_packages entry in the config and that Package Control rightly uses it to install any missing packages from the list.

But I think the question remains because I would like to install Package Control itself from the script :sweat_smile:



If you already have Sublime Text installed and subl (ST command line helper) is available in PATH, then it’s just the matter of

  1. Investigating what command is executed when someone normally does Tools -> Install Package Control ... for the first time.
  2. Finding out if subl can run commands ?

For (2), If subl can’t run commands, I wouldn’t be making this post :slight_smile:

The general syntax for running commands using subl is subl --command "<name_of_the_command> {<arguments>}"

For (1), you can simply turn on command logging in the console (by executing sublime.log_commands(True)) and finding out the command that was executed. It will be install_package_control

Putting (1) and (2) together, to install PC from the command line, you need

subl --command "install_package_control"

Coming to installing packages from the command line.

Once PC is installed, generally users would use Package Control: Install Package, which presents them a list of packages in a quick panel, whereby selecting any one would cause PC to install it.

The problem is the command behind Package Control: Install Package (install_package) doesn’t accept any arguments which we can supply to tell it to install a given package.

Fortunately, PC does provide another command hidden behind Package Control: Advanced Install Package (advanced_install_package), which can take a packages argument, which is a comma seperated list of packages. Normally, a user would pick that option from command palette and enter the packages name in an input panel.

For our case, we can simply do subl --command "advanced_install_package {\"packages\": \"LSP,LSP-pyright\"}", which would then let me install LSP & LSP-pyright from the command line. You can install any packages this way, provided the names are correct.

Final summary

  1. Installing PC from command line: subl --command "install_package_control"
  2. Installing packages from command line subl --command "advanced_install_package {\"packages\": \"LSP,LSP-pyright\"}"

Hope this helps !