How get shell linter to recognise file without shebang


I tend to put bash functions into libraries then reference them from scripts. The problem with this is that the excellent shell scripting linting/syntax highlighting etc doesn’t recognise them as bash/shell scripts.
I assume this is because there is no shebang.

Anyone know how to deal with this?


A file with the extension .sh should be recognized as a shell script. Is that not happening for you?


They don’t have a .sh extension either, as they’re just libraries.


Is there a reason why they can’t have a file extension?


No reason why they can’t; it’s just not the way I do things.


Atom needs some way to recognize the files.


Thanks; some very helpful comments there.

I was hoping for maybe directory-based metadata, or adding a hint within the individual files, like in vi:
#vi syntax=sh.


This might be useful for the multitude of JavaScript frameworks that have their own language additions, but I could see it being difficult to pull off properly. The benefit of matching grammars against file extensions and the first line of the file is that you can lay out very clear rules.

Isn’t that essentially what shebangs are? The vi feature seems a little redundant.

Aside from your personal preference, is there a reason why you can’t add shebangs or file extensions to your files?


I’m pretty sure that the shebang line is used to indicate to the OS which interpreter to use when executing the file, and the fact that editors also use it to determine language is an innovation.

It’s not just my personal preference by the way, to not use shebangs or .sh file extensions for libraries. It is recommended practice in at least one book I’ve read and is pretty common too in my experience. But I’d really prefer not to head off on a tangent related to file naming practices or coding standards as it won’t shed any light on my actual problem/question.

I am trying to find out a way to indicate to Atom that a file contains shell functions, without relying on a filename extension or shebang. If anyone can help that would be great.



My friend mentioned how Atom ‘naturally’ identifies a grammar/language at the moment. The easiest way would be to have extensions to the files. By no means is it the only way.

Method 1 - The grammar is indicated in the lower right corner. Mouse-click on this will bring up a dialog from where the correct grammar can be selected.

Method 2 - Have a script (Javascript or Coffeescript) identify the text as some grammar. The text is ‘forced’ to this grammar.

For method 2 you should identify some identification ‘marker’ that the script can use. It can be a file name or folder name for example. Meta data could also work - if you know how to extract this from the file with the script.

Not to what you are after, but the underlying idea is given: Can Atom interpret my #!/bin/bash shebang?

Your thoughts?

Set package association by file name (not extension)

Thank you that’s perfect. I’m using suggestion 1 immediately but I will investigate 2 as well.
awesome :grinning:



If ever you do bang your head against method 2, 
please keep me in the loop on your progress. (thank you)