From 1fe33087cb01ad6644a47359753f9d9e4a5564f9 Mon Sep 17 00:00:00 2001 From: Sandro-Alessio Gierens Date: Sat, 12 Aug 2023 22:31:01 +0200 Subject: [PATCH 1/7] feat: Add -w/--width to help string --- src/options/help.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/options/help.rs b/src/options/help.rs index b973e8b07..70866226b 100644 --- a/src/options/help.rs +++ b/src/options/help.rs @@ -25,6 +25,7 @@ DISPLAY OPTIONS --icons display icons --no-icons don't display icons (always overrides --icons) --hyperlink display entries as hyperlinks + -w, --width COLS set screen width in columns FILTERING AND SORTING OPTIONS -a, --all show hidden and 'dot' files From c91318d377716970c0dc3005c5ed62fed58e032e Mon Sep 17 00:00:00 2001 From: Sandro-Alessio Gierens Date: Sat, 12 Aug 2023 22:31:15 +0200 Subject: [PATCH 2/7] feat: Add -w/--width to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 16f1f896a..dcf983620 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ eza’s options are almost, but not quite, entirely unlike `ls`’s. - **--icons**: display icons - **--no-icons**: don't display icons (always overrides --icons) - **--hyperlink**: display entries as hyperlinks +- **-w**, **--width=(columns)**: set screen width in columns ### Filtering options From 72375fa126464bbb62557f576381038cb2f00935 Mon Sep 17 00:00:00 2001 From: Sandro-Alessio Gierens Date: Sat, 12 Aug 2023 22:31:39 +0200 Subject: [PATCH 3/7] feat: Add -w/--width to flags --- src/options/flags.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/options/flags.rs b/src/options/flags.rs index 4adbac4ef..5753adc68 100644 --- a/src/options/flags.rs +++ b/src/options/flags.rs @@ -14,6 +14,7 @@ pub static RECURSE: Arg = Arg { short: Some(b'R'), long: "recurse", take pub static TREE: Arg = Arg { short: Some(b'T'), long: "tree", takes_value: TakesValue::Forbidden }; pub static CLASSIFY: Arg = Arg { short: Some(b'F'), long: "classify", takes_value: TakesValue::Forbidden }; pub static DEREF_LINKS: Arg = Arg { short: Some(b'X'), long: "dereference", takes_value: TakesValue::Forbidden }; +pub static WIDTH: Arg = Arg { short: Some(b'w'), long: "width", takes_value: TakesValue::Necessary(None) }; pub static COLOR: Arg = Arg { short: None, long: "color", takes_value: TakesValue::Necessary(Some(COLOURS)) }; pub static COLOUR: Arg = Arg { short: None, long: "colour", takes_value: TakesValue::Necessary(Some(COLOURS)) }; @@ -77,7 +78,7 @@ pub static ALL_ARGS: Args = Args(&[ &VERSION, &HELP, &ONE_LINE, &LONG, &GRID, &ACROSS, &RECURSE, &TREE, &CLASSIFY, &DEREF_LINKS, - &COLOR, &COLOUR, &COLOR_SCALE, &COLOUR_SCALE, + &COLOR, &COLOUR, &COLOR_SCALE, &COLOUR_SCALE, &WIDTH, &ALL, &ALMOST_ALL, &LIST_DIRS, &LEVEL, &REVERSE, &SORT, &DIRS_FIRST, &IGNORE_GLOB, &GIT_IGNORE, &ONLY_DIRS, From df0aaa8a26c4365d0dd4404b80e6fd7376e77564 Mon Sep 17 00:00:00 2001 From: Sandro-Alessio Gierens Date: Sat, 12 Aug 2023 22:32:04 +0200 Subject: [PATCH 4/7] refactor: TerminalWidth::deduce to -w/--width TerminalWidth::deduce to respect -w/--width option --- src/options/view.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/options/view.rs b/src/options/view.rs index 4369c25fc..ac2f0b8bd 100644 --- a/src/options/view.rs +++ b/src/options/view.rs @@ -11,7 +11,7 @@ use crate::output::time::TimeFormat; impl View { pub fn deduce(matches: &MatchedFlags<'_>, vars: &V) -> Result { let mode = Mode::deduce(matches, vars)?; - let width = TerminalWidth::deduce(vars)?; + let width = TerminalWidth::deduce(matches, vars)?; let file_style = FileStyle::deduce(matches, vars)?; let deref_links = matches.has(&flags::DEREF_LINKS)?; Ok(Self { mode, width, file_style, deref_links }) @@ -145,10 +145,26 @@ impl details::Options { impl TerminalWidth { - fn deduce(vars: &V) -> Result { + fn deduce(matches: &MatchedFlags<'_>, vars: &V) -> Result { use crate::options::vars; - if let Some(columns) = vars.get(vars::COLUMNS).and_then(|s| s.into_string().ok()) { + if let Some(width) = matches.get(&flags::WIDTH)? { + let arg_str = width.to_string_lossy(); + match arg_str.parse() { + Ok(w) => { + if w >= 1 { + Ok(Self::Set(w)) + } else { + Ok(Self::Automatic) + } + } + Err(e) => { + let source = NumberSource::Arg(&flags::WIDTH); + Err(OptionsError::FailedParse(arg_str.to_string(), source, e)) + } + } + } + else if let Some(columns) = vars.get(vars::COLUMNS).and_then(|s| s.into_string().ok()) { match columns.parse() { Ok(width) => { Ok(Self::Set(width)) From 0eecaa0e43a9fda17647190ddd322fe4facab158 Mon Sep 17 00:00:00 2001 From: Sandro-Alessio Gierens Date: Sat, 12 Aug 2023 22:36:41 +0200 Subject: [PATCH 5/7] feat: Add -w/--width to manpage --- man/eza.1.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/man/eza.1.md b/man/eza.1.md index dfd2b21e0..7b84c1de8 100644 --- a/man/eza.1.md +++ b/man/eza.1.md @@ -78,6 +78,9 @@ Valid settings are ‘`always`’, ‘`automatic`’, and ‘`never`’. `--hyperlink` : Display entries as hyperlinks +`-w`, `--width=COLS` +Set screen width in columns. + FILTERING AND SORTING OPTIONS ============================= @@ -204,7 +207,7 @@ eza responds to the following environment variables: ## `COLUMNS` -Overrides the width of the terminal, in characters. +Overrides the width of the terminal, in characters, however, `-w` takes precedence. For example, ‘`COLUMNS=80 eza`’ will show a grid view with a maximum width of 80 characters. From 6cc9ad4d7ba96982600cfb00a8abaa185f4202d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christina=20S=C3=B8rensen?= Date: Sun, 13 Aug 2023 06:23:45 +0200 Subject: [PATCH 6/7] feat(completions): fish -w/--width MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christina Sørensen --- completions/fish/eza.fish | 1 + 1 file changed, 1 insertion(+) diff --git a/completions/fish/eza.fish b/completions/fish/eza.fish index bd3049dde..664de0f6b 100755 --- a/completions/fish/eza.fish +++ b/completions/fish/eza.fish @@ -28,6 +28,7 @@ complete -c eza -l git-ignore -d "Ignore files mentioned in '.gitignore'" complete -c eza -s a -l all -d "Show hidden and 'dot' files" complete -c eza -s d -l list-dirs -d "List directories like regular files" complete -c eza -s L -l level -d "Limit the depth of recursion" -x -a "1 2 3 4 5 6 7 8 9" +complete -c eza -s w -l width -d "Limits column output of grid, 0 implies auto-width" complete -c eza -s r -l reverse -d "Reverse the sort order" complete -c eza -s s -l sort -d "Which field to sort by" -x -a " accessed\t'Sort by file accessed time' From 653af3910476ed90f801aae0122ab4cf97938f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christina=20S=C3=B8rensen?= Date: Sun, 13 Aug 2023 06:24:28 +0200 Subject: [PATCH 7/7] feat(completions): zsh -w/--width MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christina Sørensen --- completions/zsh/_eza | 1 + 1 file changed, 1 insertion(+) diff --git a/completions/zsh/_eza b/completions/zsh/_eza index e144f093d..a02722028 100644 --- a/completions/zsh/_eza +++ b/completions/zsh/_eza @@ -30,6 +30,7 @@ __eza() { {-d,--list-dirs}"[List directories like regular files]" \ {-D,--only-dirs}"[List only directories]" \ {-L,--level}"+[Limit the depth of recursion]" \ + {-w,--width}"+[Limits column output of grid, 0 implies auto-width]" \ {-r,--reverse}"[Reverse the sort order]" \ {-s,--sort}="[Which field to sort by]:(sort field):(accessed age changed created date extension Extension filename Filename inode modified oldest name Name newest none size time type)" \ {-I,--ignore-glob}"[Ignore files that match these glob patterns]" \