skywind3000 / atom-shell-commands

Execute user defined shell commands (looking for new maintainers)
MIT License
37 stars 12 forks source link

use unicode escapes in config.cson #11

Open yucer opened 8 years ago

yucer commented 8 years ago

Thanks a lot for this plug-in. It saves a lot work, avoiding the need of making new plug-ins for every external command integration.

I am trying to integrate the comand for this solution: http://stackoverflow.com/a/9395552/469294

More or less:

grep --color='auto' -P -n "[\x80-\xFF]" {FileName}

so I did try:

  "atom-shell-commands":
    commands: [
      {
        name: "grep_unicode"
        command: "grep"
        arguments: [
          "--color='auto'"
          "-P"
          "-n"
          "\"[\x80-\xFF]\""
          "{FileName}"
        ]
        options:
          cwd: "{FileDir}"
          keymap: "cmd-u"
      }
    ] 

but it doesn't work:

grep","--color='auto'","-P","-n","\"[€-ÿ]\"","myFile.java"]
Usage: grep [OPTION]... PATTERN [FILE]...
Search for PATTERN in each FILE or standard input.
.....

How am I supposed to specify the escape sequence for those unicode characters ?

dqsully commented 8 years ago

Did you try escaping the backslashes? It looks like the command did what it was supposed to. In CSON, \x80 is replaced with in the string content, so write \\x80, and the string content will end up as \x80.