GithubHelp home page GithubHelp logo

clean99 / atom-shebang-set-grammar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from julien-lang/atom-shebang-set-grammar

1.0 0.0 0.0 16 KB

Atom package: detect grammar from file's first line when looks like shebang (#! /bin/...)

License: MIT License

JavaScript 100.00%

atom-shebang-set-grammar's Introduction

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)
    

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.