Coffescript to hide all docks?


I’m trying to write a short function to hide all docks (i.e. Diagnostics, Tree View, Git). This is my first coffeescript function, and I’d benefit from some guidance of where to start.

So far, I’ve put this in my

atom.commands.add 'atom-workspace',
  'custom:hide-panels': ->
    workspaceView = atom.views.getView(atom.workspace)
    atom.commands.dispatch(workspaceView, 'tree-view:hide')

and this in my keymap.cson:

 'ctrl-escape': 'custom:hide-panels'

A couple of issues:

  • Tree-view doesn’t seem to have a hide method (nor do the other docks). Is there a way of hiding it without calling a method it?
  • Are all the targets I’m trying to hide Docks? Or are some Panels? Can I get an array of all Docks / Panels without naming each in the function?



Treeview has the command tree-view:toggle, which as the name suggests toggles it open and closed.

However the other panels (including treeview) you mentioned are nowdays ‘dockable’ which means they can be part of a dock-panel and by default they are (*). There are three of those, the right, bottom and left dock. Each has its own toggle command, i.e.window:toggle-right-dock.

Unfortunately I can’t tell you how to detect if a dock is open and only call its toggle command if so. But I’m sure there’s a way.

Of course, chances are there’s a way to directly address a dock, check if it’s open and then close it if so without going through the commands. Which would probably the better way.

* I don’t really know the exact details so this all is crudely based on my own experience with the dock toggle commands.


Disclaimer: untested

atom.commands.add 'atom-workspace',
  'custom:hide-docks': ->

API docs at and


That’s brilliant - thank you very much @Wllu