Skip to content

"ls" functionality when called with a directory #971

@samuelcolvin

Description

@samuelcolvin

(I'm sorry if this is a duplicate, I can't imagine it's not, yet I've search a lot and can't find anything)

It would be wonderful if bat behaved like ls -lh ... when executed with a directory as an arg.

This would be particularly useful when looking for a file to display; currently I often end up replacing bat with ls -lh at the beginning of a long path.

Obviously it would be useful if the output was highlighted unlike normal ls.

The main downside I can imagine would be confusion when "conbatenating" multiple files: if I accidentally included a directory instead of a file as one of the paths, however:

  1. unlike cat I imagine bat is rarely used for this, especially in scripts
  2. bat could continue to use a non-zero exit code when executed with a path to show it's not the primary intended purpose, while still showing the list of files - I'm not advocating this, just a potential work around

If this is something you'd be interested in, I'd be willing to have a crack at a PR, through I a somewhat novice rust developer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions