How to add Atom `Restart` Button to Atom Tool-Bar

Creating a command of atom restart tool-bar button is easy through the init.coffee file
and the CommandRegistry API:

Step 1. Install atom toolbar packages

  • tool-bar : This package provides extensible tool bar for Atom.

this package by itself adds an empty toolbar. To propagate it with icons you can install toolbar plugins.

  • flex-tool-bar : This is a plugin for the Atom Tool Bar package (tool-bar).

You can install atom packages at the Atom Settings > Install pane (Ctrl-Comma key),
or Terminal as the following:

$ apm install tool-bar flex-tool-bar

Step 2. Create a atom command (user.restart) into init.coffee file

Go to Atom Menu Bar: Edit > Init Script... and edit:

~/.atom/init.coffee

# Restart Atom
atom.commands.add 'atom-workspace', 'user:restart': (event) ->
  atom.restartApplication()

Then you can use a toolbar plugin package like flex-tool-bar to create a button if you want.

To edit your toolbar plugin config file, type Flex Tool Bar: Edit Config File and select it in the Atom command palette (Ctrl-Shfit-P key).

And then if ~/.atom/toolbar.cson file is opening, edit the file as following:

~/.atom/toolbar.cson

# This file is used by Flex Tool Bar to create buttons on your Tool Bar.
# For more information how to use this package and create your own buttons,
#   read the documentation on https://atom.io/packages/flex-tool-bar

[
  {
    type: 'button'
    tooltip: 'Open File'
    callback: 'application:open-file'
    icon: 'document-text'
    iconset: 'ion'
  },
  {
    type: 'button'
    tooltip: 'Open Folder'
    callback: 'application:open-folder'
    icon: 'folder'
    iconset: 'ion'
  },
  {
    type: 'button'
    tooltip: 'Save File'
    callback: 'core:save'
    icon: 'archive'
    iconset: 'ion'
  },
  {
    type: 'button'
    tooltip: 'Git Control'
    dependency: 'git-control'
    callback: 'git-control:toggle'
    icon: 'bullseye'
    iconset: 'fa'
  },
  {
    type: 'button'
    tooltip: 'Git Projects'
    dependency: 'git-projects'
    callback: 'git-projects:toggle'
    icon: 'git'
    iconset: 'fa'
  },
  {
    type: 'button'
    tooltip: 'List projects'
    dependency: 'project-manager'
    callback: 'project-manager:list-projects'
    icon: 'file-submodule'
  },
  {
    type: 'spacer'
  },
  {
    type: 'button'
    tooltip: 'Split screen - Horizontally'
    callback: 'pane:split-right'
    icon: 'columns'
    iconset: 'fa'
  },
  {
    type: 'button'
    tooltip: 'Split screen - Vertically'
    callback: 'pane:split-down'
    icon: 'columns'
    iconset: 'fa'
  },
  {
    type: 'spacer'
  },
  {
    type: 'button'
    tooltip: 'Merge Conflicts'
    dependency: 'merge-conflicts'
    callback: 'merge-conflicts:detect'
    icon: 'code-fork'
    iconset: 'fa'
  },
  {
    type: 'button'
    tooltip: 'Toggle Fullscreen'
    callback: 'window:toggle-full-screen'
    icon: 'arrows-alt'
    iconset: 'fa'
  },
  {
    type: 'button'
    tooltip: 'Toggle Sidebar'
    callback: 'tree-view:toggle'
    icon: 'sitemap'
    iconset: 'fa'
  },
  {
    type: 'button'
    tooltip: 'Toggle Minimap'
    dependency: 'minimap'
    callback: 'minimap:toggle'
    icon: 'map'
    iconset: 'ion'
  },
  {
    type: 'spacer'
  },
  {
    type: 'button'
    tooltip: 'Auto indent (selection)'
    callback: 'editor:auto-indent'
    icon: 'indent'
    iconset: 'fa'
  },
  {
    type: 'button'
    tooltip: 'Fold all'
    callback: 'editor:fold-all'
    icon: 'level-up'
    iconset: 'fa'
  },
  {
    type: 'button'
    tooltip: 'Unfold all'
    callback: 'editor:unfold-all'
    icon: 'level-down'
    iconset: 'fa'
  },
  {
    type: 'spacer'
  },
  {
    type: 'button'
    tooltip: 'Reload Window'
    callback: 'window:reload'
    icon: 'refresh'
    iconset: 'ion'
    style:
      color: "#0098ff"
  },
  {
    type: 'button'
    tooltip: 'Toggle Developer Tools'
    callback: 'window:toggle-dev-tools'
    icon: 'bug'
  },
  {
    type: 'button'
    tooltip: 'Open Settings View'
    callback: 'settings-view:open'
    icon: 'gear-a'
    iconset: 'ion'
  },
  {
    type: "button"
    icon: "ios-cog-outline"
    iconset: 'ion'
    callback: "flex-tool-bar:edit-config-file"
    tooltip: "Edit Tool Bar"
  },
  {
    type: 'spacer'
  },
  {
    type: 'button'
    tooltip: 'Restart Atom... '
    callback: 'user:restart'
    icon: 'load-a'
    iconset: 'ion'
    style:
      color: "#FA4F28"
  }
]

Supported icon sets

Finally, Restart Atom

And if you want to change the settings, go to “Menu Bar> Edit> Preferences”, Settings > Packages pane (Ctrl-Comma key).

In the pane, search tool bar and set the tool-bar, flex-tool-bar settings.

To toggle (show / hide) Tool-Bar buttons, press the shortcut Ctrl-Alt-T key or click the Atom Menu Bar > View > Toggle Tool Bar menu.

add-atom-toolbar-restart-button

Leave a Reply