• Packages
  • Themes
  • Documentation
  • Blog
  • Discussions
Sign in

shebang-set-grammar

Detect grammar from file's first line when looks like shebang (#! /bin/...)
  • #grammar
  • #shebang
  • ##!
julien-lang
0.8.0 1,488
5
  • Repo
  • Bugs
  • Versions
  • License
Flag as spam or malicious

shebang-set-grammar Atom package

shebang-set-grammar is a package for Atom that auto-detect the files' grammar from the shebang.

When opening a file with Atom, let's say a Python file for instance, Atom automaticaly set the Python grammar (syntax highlighting). This is done by looking at the file extension ".py". Atom knows that a .py extension means Python. ".sh" => shell, ".php" => PHP, ".js" => Java script...

But, as a Unix user, I often write scripts without defining the script language in the file extention. I prefer to make the file executable and define how to execute it in the shebang:

  • bash

       #! /bin/bash
    
  • perl

      #! /bin/perl -W
    
  • python

      #! /usr/bin/env python
    

In that case, when Atom open this file, the grammar is not detected. I can define it manually in Atom but I would prefer if it would be done automaticaly by reading the shebang.

This is what this module is doing!

Process description

  • straightforward

        #! /usr/bin/python     =>     python     =>     set-grammar(source.python)
    
  • extra arguments

        #! /usr/bin/python -a -b -c      =>      python     =>     set-grammar(source.python)
    
  • wrapper programm

        #! /usr/bin/env python -a -b      =>     python     =>     set-grammar(source.python)
    
  • aliases - when binary is different from Atom's grammar name

        #! /bin/sh      =>      sh      =(alias)=>     shell      => set-grammar(source.shell)
    
        #! /bin/bash      =>      bash      =(alias)=>     shell       => set-grammar(source.shell)
    

I think this package is bad news.

Good catch. Let us know what about this package looks wrong to you, and we'll investigate right away.

  • Terms of Use
  • Privacy
  • Code of Conduct
  • Releases
  • FAQ
  • Contact
with by