mirror of
https://github.com/lsd-rs/lsd
synced 2025-01-18 22:43:59 +00:00
✨ should not overwrite tree layout when tty not available
Signed-off-by: Wei Zhang <kweizh@gmail.com>
This commit is contained in:
parent
b64905709a
commit
c433da0dfd
2 changed files with 11 additions and 5 deletions
15
src/core.rs
15
src/core.rs
|
@ -64,12 +64,17 @@ impl Core {
|
|||
|
||||
let icon_separator = flags.icons.separator.0.clone();
|
||||
|
||||
// The output is not a tty, this means the command is piped. e.g.
|
||||
//
|
||||
// lsd -l | less
|
||||
//
|
||||
// Most of the programs does not handle correctly the ansi colors
|
||||
// or require a raw output (like the `wc` command).
|
||||
if !tty_available {
|
||||
// The output is not a tty, this means the command is piped. (ex: lsd -l | less)
|
||||
//
|
||||
// Most of the programs does not handle correctly the ansi colors
|
||||
// or require a raw output (like the `wc` command).
|
||||
flags.layout = Layout::OneLine;
|
||||
// we should not overwrite the tree layout
|
||||
if flags.layout != Layout::Tree {
|
||||
flags.layout = Layout::OneLine;
|
||||
}
|
||||
|
||||
flags.literal = Literal(true);
|
||||
};
|
||||
|
|
|
@ -322,6 +322,7 @@ fn test_dereference_link_broken_link_output() {
|
|||
.stdout(predicate::str::starts_with("l????????? ? ? ? ?"));
|
||||
}
|
||||
|
||||
/// should work both tty available and not
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn test_show_folder_content_of_symlink() {
|
||||
|
|
Loading…
Reference in a new issue