Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for embeded AWK syntax highlighting #212

Open
jpotter23 opened this issue Mar 18, 2024 · 1 comment
Open

Add support for embeded AWK syntax highlighting #212

jpotter23 opened this issue Mar 18, 2024 · 1 comment

Comments

@jpotter23
Copy link

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 :)

@xonixx
Copy link
Owner

xonixx commented Mar 19, 2024

Related: #123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants