How to launch a command from the context menu


How can I add this scrpit (taken here will be in the Init File) in the context menu ?

atom.commands.add 'atom-text-editor', 'markdown:paste-as-link', ->
  return unless editor = atom.workspace.getActiveTextEditor()

  selection = editor.getLastSelection()
  clipboardText =


Any advice would be very precious.



I recommend looking at the API docs

atom.contextMenu.add {
  "atom-text-editor": [{
    label: "Paste as link"
    command: "markdown:paste-as-link"


Thanks a lot both of you, it’s exactly what I was looking for!