# Installing Packages From The Command Line

**URL:** <https://forum.sublimetext.com/t/installing-packages-from-the-command-line/64029>\
**Category:** Ideas and Feature Requests\
**Created:** [May 17, 2022, 9:00am UTC](https://forum.sublimetext.com/t/installing-packages-from-the-command-line/64029 "2022-05-17T09:00:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tasugo](https://forum.sublimetext.com/letter_avatar_proxy/v4/letter/t/58956e/32.png) [@tasugo](https://forum.sublimetext.com/u/tasugo)\
**Post date:** [May 17, 2022, 9:00am UTC](https://forum.sublimetext.com/t/installing-packages-from-the-command-line/64029/1 "2022-05-17T09:00:47Z")

</div>

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:

```auto
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? 🙂

---

<div class="post-metadata">

**Author:** ![milkman](https://forum.sublimetext.com/user_avatar/forum.sublimetext.com/milkman/32/58907_2.png) [@milkman](https://forum.sublimetext.com/u/milkman)\
**Post date:** [May 17, 2022, 9:50am UTC](https://forum.sublimetext.com/t/installing-packages-from-the-command-line/64029/2 "2022-05-17T09:50:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tasugo](https://forum.sublimetext.com/letter_avatar_proxy/v4/letter/t/58956e/32.png) [@tasugo](https://forum.sublimetext.com/u/tasugo)\
**Post date:** [May 17, 2022, 10:05am UTC](https://forum.sublimetext.com/t/installing-packages-from-the-command-line/64029/3 "2022-05-17T10:05:59Z")

</div>

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 😅

---

<div class="post-metadata">

**Author:** ![UltraInstinct05](https://forum.sublimetext.com/letter_avatar_proxy/v4/letter/u/85e7bf/32.png) [@UltraInstinct05](https://forum.sublimetext.com/u/UltraInstinct05)\
**Post date:** [May 17, 2022, 10:50am UTC](https://forum.sublimetext.com/t/installing-packages-from-the-command-line/64029/4 "2022-05-17T10:50:28Z")

</div>

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 🙂

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 !
