node.jsgitshellgruntjsgrunt-shell

(grunt) shell: Command to open default editor


Is it possible to run the default editor (which is set for git) using grunt-shell to open and edit an file (on ubuntu)?

In my attempt it is running sublime, but every local system is using a different editor...

grunt.initConfig({
  shell: {
    changelog: {
      options: {
        stdinRawMode: true
      },
      command: 'subl -w CHANGELOG.md'
    }
  }
})

Solution

  • Try:

    command: '`git var GIT_EDITOR` CHANGELOG.md'
    

    git var GIT_EDITOR get the configured editor — from the environment var, from local or global config, or fallback to other environment variables (VISUAL/EDITOR) or default vi.