Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

UziTech/terminal-commands

Repository files navigation

Actions Status Dependency Status

terminal-commands package

Setup commands to run in the terminal from the command palette, context menu, or key binding.

Note Depends on a terminal package like x-terminal to run!

screenshot

Example

// in ~/.atom/terminal-commands.json
{
  "echo:file": "echo ${file}",
  "echo:files": ["echo test", "echo ${files}"],
  "echo:dir": {
    "commands": "echo ${dir}",
    "key": "alt-d",
    "priority": 0
  },
  "echo:project": {
    "commands": "echo ${project}",
    "key": "alt-p",
    "priority": 100,
    "selector": ".tree-view"
  }
}

image


image

Options

The commands in terminal-commands.json should be formatted as one of the following:

  • Single string command:
{
  "namespace:action": "command"
}
  • Multiple string commands:
{
  "namespace:action": ["command 1", "command 2"],
}
  • Commands object with the following keys:
{
  "namespace:action": {
    "commands": "commands", // (required) Can be a string or an array of strings
    "key": "alt-k", // (optional) A default key binding
    "priority": 100, // (optional) Key binding priority. Default = 0
    "selector": ".css-selector" // (optional) Selector to limit the key binding and context menu. Default = "atom-workspace"
  }
}

Placeholders

Placeholders can be used so commands can use current command target in the commands. The command target will be the active editor if from the command palette, or selected files if from the tree-view context menu.

  • ${file} - Replaced with the first target file path
  • ${files} - Replaced with the targets file paths separated by space
  • ${dir} - Replaced with the first target directory path
  • ${project} - Replaced with the first target file's project path
  • ${line} - Replaced with the line number of the most recently added cursor.