intellij-awk icon indicating copy to clipboard operation
intellij-awk copied to clipboard

Add support for embeded AWK syntax highlighting

Open jpotter23 opened this issue 1 year ago • 1 comments

I frequently use bash with embed GAWK in my tools. In order to syntax highlight the awk sections, I have to toggle between shell and awk syntax, which gets tedious and makes it so that refactoring gets clunky as it cannot tell where bash ends and GAWK begins. Example:

Begin of FIle: Test.txt

<Ips>
    <Ip>192.168.0.1</Ip>
    <Ip>192.168.1.1</Ip>
    <Ip>192.168.3.7</Ip>
    <Ip>192.168.4.1</Ip>
    <Ip>192.168.5.1</Ip>
</Ips>

End of File: Test.txt

Begin BASH/AWK Script Example:

#!/usr/local/bin
  BASH_VAR1="BASH1"
  BASH_VAR2="BASH2"
  cat Test.txt | awk  \
      -v "BASH_VAR1=$BASH_VAR1"\
      -v "BASH_VAR2=$BASH_VAR2" '
      BEGIN {
          AWK_VAR1="AWK1";
          AWK_VAR2="AWK2";
          split("",safe_ips);
      }
  
      /<Ip>.*<\/Ip>/{
        ip=gensub("</?Ip>","","g",$1);
        safe_ips[ip]=ip;
      }
  
      END {
        for (e in safe_ips) {
          print "\t",BASH_VAR1,AWK_VAR1,e;
        }
      }
  '  |  column -t

I've seen embed awk syntax highlighting within VIM before (see answer here) was hoping to have that support after moving to a full IDE like PhpStorm.

Here's to hoping for better tomorrow :)

jpotter23 avatar Mar 18 '24 20:03 jpotter23

Related: https://github.com/xonixx/intellij-awk/issues/123

xonixx avatar Mar 19 '24 00:03 xonixx