Skip to content

Shebang support #69

Closed
Closed

Description

@friedev

dprint has support for mapping shebangs to file extensions, but dprint-plugin-exec does not honor these mappings, and provides no equivalent option for shebang detection itself.

Ideally, exec.commands.exts should accept file extensions mapped from shebangs by dprint.

If that's not possible, adding a shebangs list to commands objects would work too. For instance, adding "shebangs": ["#!/bin/sh"] to a command would cause it to run for any file with a #!/bin/sh shebang and no extension, following the same rules as dprint.

Example

Here's a minimal example setup to reproduce this using fish_indent:

dprint.jsonc:

{
  "shebangs": {
    "#!/usr/bin/env fish": "fish",
  },
  "exec": {
    "cwd": "${configDir}",
    "commands": [
      {
        "command": "fish_indent",
        "exts": ["fish"],
      },
    ],
  },
  "plugins": [
    "npm:@dprint/[email protected]/plugin.json@14842df8dbb117b521c6bdfd171fd22d25c19d9588de65785cccf2caf59c4780"
  ],
}

example (executable fish script with shebang and no extension):

#!/usr/bin/env fish
    echo hi

example.fish (executable fish script with extension and no shebang):

    echo hi

Running dprint check detects the indentation error in example.fish but not in example:

$ dprint check
from /tmp/dprint-plugin-exec/example.fish:
  1|-····echo·hi
1  |+echo·hi
--
Found 1 not formatted file. Run dprint fmt to fix.

Activity

  1. dsherret commented on Oct 11, 2026

    @dsherret
    Member

    Will comment back once this is released. Requires both a dprint (dprint/dprint#1349) and a dprint-plugin-exec release

  2. dsherret commented on Oct 11, 2026

    @dsherret
    Member

    Should work now in dprint 0.63.0 (just released) and dprint-plugin-exec 0.8.0

  3. friedev commented on Oct 12, 2026

    @friedev
    Author

    Thanks for the quick fix! I'll check it out when the new version gets published on Arch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions