Start Atom with selected packages


#1

Is there a way to start Atom only with a list of selected packages? I checked command line options but nothing appears to be what I’m looking for. I know there is a --safe option, but it is not the same thing.

I did look at Atom source and found something that appears to be the one that handles packages for devMode and safeMode:

[src/package-manager.coffee]
constructor: ({configDirPath, @devMode, safeMode, @resourcePath}) ->
  @emitter = new Emitter
  @packageDirPaths = []
  unless safeMode
    if @devMode
      @packageDirPaths.push(path.join(configDirPath, "dev", "packages"))
    @packageDirPaths.push(path.join(configDirPath, "packages"))

The idea is to create something like profiles, so I could start atom with a selected list of packages for each kind of work that I pretend to do with Atom.

For instance, for each language/framework development, you have a list of packages that make sense to be used, but obviously there is another list that do not. And if I would like to make Atom a Notepad replacement, for clean/easy/fast editing non formatted text, the list would be even smaller. Today I have to keep all packages enabled (76 core + 32 community).

If the code in src/package-manager.coffee is the one, I guess I would only be able to have this profiles changing the core packages.

Any ideas?


Per folder/project packages
#2

I also really miss that feature.
What works is, that you can “star” all packages you like and then install the starred ones.
I think you could create multiple accounts and star different sets of packages and then install the packages of those accounts.

Otherwise, I’m very interested in this question :slight_smile: Would be great to have a “package.json” like config file and maybe even to install atom locally? (so i can have different packages for different projects?)


#3

I think there currently isn’t a way to do this. You could write a script that modifies the disabledPackages in ~/.atom/config.cson. Something like this: (it requires node and the season npm module)

#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var season = require('season');

var ATOM_HOME = path.join(process.env.HOME, '.atom');
var config = season.readFileSync(path.join(ATOM_HOME, 'config.cson'));

var disabledPackages = config['*'].core.disabledPackages;
fs.readdirSync(path.join(ATOM_HOME, 'packages')).forEach(function(package) {
  if(process.argv.indexOf(package) > -1) {
    if((index = disabledPackages.indexOf(package)) > -1) disabledPackages.splice(index, 1);
  } else {
    disabledPackages.push(package);
  }
});

season.writeFileSync(path.join(ATOM_HOME, 'config.cson'), config);

You can use it like this: <script-name> package-name1 package-name2 ... && atom and it may need a few changes as I haven’t tested this.


#4

I knew @olmokramer would have some script to handle it :smile:

That’s a great idea. I will give it a try tomorrow and see how it works.

But if instead of a script, to be able to add it to Atom itself, it would probably be in the core itself, not a core package, right? I’m asking because I had tried to build atom, but had no success :disappointed: . And being a package, would be a lot easier, just using devMode / apm link -dev.

Thanks


#5

You would probably need to add a hook to Atom core to enable this in any deep way, yes. Otherwise, I would suspect that all packages would get activated just for some of them to get deactivated, which seems antithetical to your goals :grinning:


#6

Hahaha, good point :smile:

So to add a hook or another command line option, I need to be able to build atom from source first. I hope to have some luck this time …

Thanks


#7

I was wondering if @olmokramer had tested its script. It worked perfectly as is :smile:. I would make only one minor change, adding the core packages to be disabled too. Easy to do now.

Meanwhile I found a package that uses a similar technique (using disabled packages). It’s called package-switch. I did some tests and it works as advised.

But using the disabled packages technique has a weak point. Since I run more than one instance of Atom, and sometimes, each one with a different profile, the disabled packages starts to conflict :confused:.

Even so, it’s a good start, and gave me a great insight about Atom performance. I left less than 10 packages at start and Atom started almost instantaneously. The perfect Notepad replacement that I wanted :smile:

I added an issue about my build error. When I have success building Atom I will try to add this profile idea and maybe, add a PR to the core.

Thanks for your help.


#8

Maybe somebody could write a wrapper around the “atom cli” and make it installable via “npm” :smile:
So I would do “npm install atom -g” or i can even install it locally if i want.

What it would do is to offer a cli tool that enables me to start atom (but the start is sensitive to a “package.json” in the curent path ($ pwd)). So basically I can have a “per project configuration” of atom and the activated themes and plugins.

Ideally, when I right-click a folder in the “tree view” to open it in another atom window and that folder has such a “package.json”, atom might switch themes and activated/deactivated plugins and the like…