Installing Packages From The Command Line

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 !

2 Likes