Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use bat to view directory #1156

Closed
KSXGitHub opened this issue Aug 27, 2020 · 4 comments
Closed

Use bat to view directory #1156

KSXGitHub opened this issue Aug 27, 2020 · 4 comments
Labels
feature-request New feature or request

Comments

@KSXGitHub
Copy link

KSXGitHub commented Aug 27, 2020

Problem

When using terminal, I have a habit of pressing UP arrow and edit the previous command.

Currently, I have to use 2 different commands to view directory and file. It is very cumbersome when I have to change "ls" part of the previous command to "bat" to view a file.

So I think that it would be very helpful if bat can just display content of a directory.

Suggestion

Add a flag called --dir-viewer that takes a command. For example:

bat --dir-viewer='ls -A --color=always' file1 file2 dir1 dir2 file3 dir3

The above command would:

  1. Display content of file1.
  2. Display content of file2.
  3. Execute ls -A --color=always dir1 and display output that fits within decoration frame as if it was content of a file.
  4. Execute ls -A --color=always dir2 and display output that fits within decoration frame as if it was content of a file.
  5. Display content of file3.
  6. Execute ls -A --color=always dir3 and display output that fits within decoration frame as if it was content of a file.
@KSXGitHub KSXGitHub added the feature-request New feature or request label Aug 27, 2020
@KSXGitHub KSXGitHub changed the title Feature Request: Use bat to view directory Use bat to view directory Aug 27, 2020
@eggbean
Copy link

eggbean commented Aug 28, 2020

You could write a bash function if you really want this unusual behaviour.

@KSXGitHub
Copy link
Author

@eggbean bat's output has decoration.

@sharkdp
Copy link
Owner

sharkdp commented Sep 7, 2020

@KSXGitHub Thank you for your feedback, but this is probably not going to happen. As @eggbean suggest, I think this would be a good fit for a wrapper script / shell function.

@sharkdp sharkdp closed this as completed Sep 7, 2020
@superpupervlad
Copy link

If someone want ready-to-use bash script please check this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants