diff --git a/babi/highlight.py b/babi/highlight.py
index cbd2f75..284ac53 100644
--- a/babi/highlight.py
+++ b/babi/highlight.py
@@ -10,6 +10,7 @@ from typing import Tuple
 from typing import TypeVar
 
 from identify.identify import tags_from_filename
+from identify.identify import tags_from_path
 
 from babi._types import Protocol
 from babi.fdict import FChainMap
@@ -721,7 +722,11 @@ class Grammars:
         return self.compiler_for_scope('source.unknown')
 
     def compiler_for_file(self, filename: str, first_line: str) -> Compiler:
-        for tag in tags_from_filename(filename) - {'text'}:
+        try:
+            tags = tags_from_path(filename)
+        except ValueError:
+            tags = tags_from_filename(filename)
+        for tag in tags - {'text'}:
             try:
                 # TODO: this doesn't always match even if we detect it
                 return self.compiler_for_scope(f'source.{tag}')

diff --git a/tests/highlight_test.py b/tests/highlight_test.py
index db8d2b7..3a72e5a 100644
--- a/tests/highlight_test.py
+++ b/tests/highlight_test.py
@@ -1,5 +1,7 @@
 from __future__ import annotations
 
+import stat
+
 import pytest
 
 from babi.highlight import highlight_line
@@ -13,6 +15,17 @@ def test_grammar_matches_extension_only_name(make_grammars):
     assert compiler.root_state.entries[0].scope[0] == 'shell'
 
 
+def test_file_without_extension(tmpdir, make_grammars):
+    f = tmpdir.join('f')
+    f.write('#!/usr/bin/env python3')
+    f.chmod(stat.S_IRWXU)
+
+    data = {'scopeName': 'source.python', 'patterns': []}
+    grammars = make_grammars(data)
+    compiler = grammars.compiler_for_file(str(f), f.read())
+    assert compiler.root_state.entries[0].scope[0] == 'source.python'
+
+
 def test_grammar_matches_via_identify_tag(make_grammars):
     grammars = make_grammars({'scopeName': 'source.ini', 'patterns': []})
     compiler = grammars.compiler_for_file('setup.cfg', '')

utilize identify's shebang detection for grammar when possible
an example:

```python
#!/usr/bin/env python3
print('hello')
```

this file saved as `foo/install` gets highlighted incorrectly as shell, but we can utilize `tags_from_path` to identify this as `python` earlier on
tests/highlight_test.py::test_file_without_extension
tests/highlight_test.py::test_grammar_matches_extension_only_name tests/highlight_test.py::test_grammar_matches_via_identify_tag tests/highlight_test.py::test_backslash_a tests/highlight_test.py::test_backslash_g_inline tests/highlight_test.py::test_backslash_g_next_line tests/highlight_test.py::test_end_before_other_match tests/highlight_test.py::test_backslash_g_captures_nl tests/highlight_test.py::test_backslash_g_captures_nl_next_line tests/highlight_test.py::test_while_no_nl tests/highlight_test.py::test_complex_captures tests/highlight_test.py::test_captures_multiple_applied_to_same_capture tests/highlight_test.py::test_captures_ignores_empty tests/highlight_test.py::test_captures_ignores_invalid_out_of_bounds tests/highlight_test.py::test_captures_begin_end tests/highlight_test.py::test_captures_while_captures tests/highlight_test.py::test_captures_implies_begin_end_captures tests/highlight_test.py::test_captures_implies_begin_while_captures tests/highlight_test.py::test_include_self tests/highlight_test.py::test_include_repository_rule tests/highlight_test.py::test_include_with_nested_repositories tests/highlight_test.py::test_include_other_grammar tests/highlight_test.py::test_include_base tests/highlight_test.py::test_rule_with_begin_and_no_end tests/highlight_test.py::test_begin_end_substitute_special_chars tests/highlight_test.py::test_backslash_z tests/highlight_test.py::test_buggy_begin_end_grammar