Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ eza’s options are almost, but not quite, entirely unlike `ls`’s. Quick overv
- **--colo[u]r-scale=(field)**: highlight levels of `field` distinctly(all, age, size)
- **--color-scale-mode=(mode)**: use gradient or fixed colors in --color-scale. valid options are `fixed` or `gradient`
- **--icons=(when)**: when to display icons (always, auto, never)
- **--hyperlink**: display entries as hyperlinks
- **--hyperlink=(when)**: when to display entries as hyperlinks (always, auto, never)
- **--absolute=(mode)**: display entries with their absolute path (on, follow, off)
- **-w**, **--width=(columns)**: set screen width in columns

Expand Down
5 changes: 5 additions & 0 deletions completions/bash/eza
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ _eza() {
return
;;

--hyperlink)
mapfile -t COMPREPLY < <(compgen -W 'always automatic auto never' -- "$cur")
return
;;

-L|--level)
mapfile -t COMPREPLY < <(compgen -W '{0..9}' -- "$cur")
return
Expand Down
7 changes: 6 additions & 1 deletion completions/fish/eza.fish
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ complete -c eza -l icons -d "When to display icons" -x -a "
never\t'Never display icons'
"
complete -c eza -l no-quotes -d "Don't quote file names with spaces"
complete -c eza -l hyperlink -d "Display entries as hyperlinks"
complete -c eza -l hyperlink -d "When to display entries as hyperlinks" -x -a "
always\t'Always display entries hyperlinks'
auto\t'Display hyperlinks if standard output is a terminal'
automatic\t'Display hyperlinks if standard output is a terminal'
never\t'Never display entries as hyperlinks'
"
complete -c eza -l follow-symlinks -d "Drill down into symbolic links that point to directories"
complete -c eza -l absolute -d "Display entries with their absolute path" -x -a "
on\t'Show absolute path for listed entries'
Expand Down
2 changes: 1 addition & 1 deletion completions/nush/eza.nu
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export extern "eza" [
--colour-scale-mode # Use gradient or fixed colors in --colour-scale
--icons # When to display icons
--no-quotes # Don't quote file names with spaces
--hyperlink # Display entries as hyperlinks
--hyperlink # When to display entries as hyperlinks
--absolute # Display entries with their absolute path
--follow-symlinks # Drill down into symbolic links that point to directories
--group-directories-first # Sort directories before other files
Expand Down
7 changes: 6 additions & 1 deletion completions/pwsh/_eza.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ Register-ArgumentCompleter -Native -CommandName 'eza' -ScriptBlock {
ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, "ParameterValue", $_)}
break
}
'*;--hyperlink' {
$ArrayWhen |
ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, "ParameterValue", $_)}
break
}
'*;--all' {
[CompletionResult]::new('--show-symlinks' ,'listfilessyl' , [CompletionResultType]::ParameterName, 'explicitly show symbolic links (for use with --only-dirs | --only-files)')
[CompletionResult]::new('--no-symlinks' ,'listfilessyl' , [CompletionResultType]::ParameterName, 'do not show symbolic links')
Expand Down Expand Up @@ -158,7 +163,7 @@ Register-ArgumentCompleter -Native -CommandName 'eza' -ScriptBlock {
# [CompletionResult]::new('--colour-scale-mode' ,'colorscalemode' , [CompletionResultType]::ParameterName, 'use gradient or fixed colors in --color-scale (fixed, gradient)')
[CompletionResult]::new('--icons' ,'icons' , [CompletionResultType]::ParameterName, 'when to display icons (always, auto, never)')
[CompletionResult]::new('--no-quotes' ,'noquotes' , [CompletionResultType]::ParameterName, 'don''t quote file names with spaces')
[CompletionResult]::new('--hyperlink' ,'hyperlink' , [CompletionResultType]::ParameterName, 'display entries as hyperlinks')
[CompletionResult]::new('--hyperlink' ,'hyperlink' , [CompletionResultType]::ParameterName, 'when to display entries as hyperlinks (always, auto, never)')
[CompletionResult]::new('--absolute' ,'absolute' , [CompletionResultType]::ParameterName, 'display entries with their absolute path (on, follow, off)')
[CompletionResult]::new('--follow-symlinks' ,'followsymlinks' , [CompletionResultType]::ParameterName, 'drill down into symbolic links that point to directories')
# [CompletionResult]::new('-w' ,'widths' , [CompletionResultType]::ParameterName, 'set screen width in columns')
Expand Down
2 changes: 1 addition & 1 deletion completions/zsh/_eza
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ __eza() {
--colo{,u}r-scale-mode"[Use gradient or fixed colors in --color-scale]:(mode):(fixed gradient)" \
--icons="[When to display icons]:(when):(always auto automatic never)" \
--no-quotes"[Don't quote filenames with spaces]" \
--hyperlink"[Display entries as hyperlinks]" \
--hyperlink="[When to display entries as hyperlinks]:(when):(always auto automatic never)" \
--absolute"[Display entries with their absolute path]:(mode):(on follow off)" \
--follow-symlinks"[Drill down into symbolic links that point to directories]" \
--group-directories-first"[Sort directories before other files]" \
Expand Down
7 changes: 6 additions & 1 deletion man/eza.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,14 @@ When used without a value, defaults to ‘`automatic`’.
`--no-quotes`
: Don't quote file names with spaces.

`--hyperlink`
`--hyperlink=WHEN`
: Display entries as hyperlinks

Valid settings are ‘`always`’, ‘`automatic`’ (‘`auto`’ for short), and ‘`never`’.
When used without a value, defaults to ‘`automatic`’.

`automatic` or `auto` will display hyperlinks only when the standard output is connected to a real terminal. If `eza` is ran while in a `tty`, or the output of `eza` is either redirected to a file or piped into another program, hyperlinks will not be used. Setting this option to ‘`always`’ causes `eza` to always display hyperlinks, while ‘`never`’ disables the use of hyperlinks.

`-w`, `--width=COLS`
: Set screen width in columns.

Expand Down
13 changes: 8 additions & 5 deletions src/options/file_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,15 @@ impl QuoteStyle {

impl EmbedHyperlinks {
fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
let flagged = matches.has(&flags::HYPERLINK)?;

if flagged {
Ok(Self::On)
if let Some(word) = matches.get(&flags::HYPERLINK)? {
match word.to_str() {
Some("always") => Ok(Self::Always),
Some("auto" | "automatic") => Ok(Self::Automatic),
Some("never") => Ok(Self::Never),
_ => Err(OptionsError::BadArgument(&flags::HYPERLINK, word.into()))?,
}
} else {
Ok(Self::Off)
Ok(Self::Never)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/options/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub static TIME: Arg = Arg { short: Some(b't'), long: "time", take
pub static ACCESSED: Arg = Arg { short: Some(b'u'), long: "accessed", takes_value: TakesValue::Forbidden };
pub static CREATED: Arg = Arg { short: Some(b'U'), long: "created", takes_value: TakesValue::Forbidden };
pub static TIME_STYLE: Arg = Arg { short: None, long: "time-style", takes_value: TakesValue::Necessary(Some(TIME_STYLES)) };
pub static HYPERLINK: Arg = Arg { short: None, long: "hyperlink", takes_value: TakesValue::Forbidden };
pub static HYPERLINK: Arg = Arg { short: None, long: "hyperlink", takes_value: TakesValue::Optional(Some(WHEN), "auto") };
pub static MOUNTS: Arg = Arg { short: Some(b'M'), long: "mounts", takes_value: TakesValue::Forbidden };
pub static SMART_GROUP: Arg = Arg { short: None, long: "smart-group", takes_value: TakesValue::Forbidden };
const TIMES: Values = &["modified", "changed", "accessed", "created"];
Expand Down
2 changes: 1 addition & 1 deletion src/options/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ DISPLAY OPTIONS
--colo[u]r-scale-mode use gradient or fixed colors in --color-scale (fixed, gradient)
--icons=WHEN when to display icons (always, auto, never)
--no-quotes don't quote file names with spaces
--hyperlink display entries as hyperlinks
--hyperlink=WHEN when to display entries as hyperlinks (always, auto, never)
--absolute display entries with their absolute path (on, follow, off)
--follow-symlinks drill down into symbolic links that point to directories
-w, --width COLS set screen width in columns
Expand Down
19 changes: 15 additions & 4 deletions src/output/file_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,14 @@ pub enum ShowIcons {
/// Whether to embed hyperlinks.
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum EmbedHyperlinks {
Off,
On,
/// Never embed hyperlinks, even when output is going to a terminal.
Never,

/// Embed hyperlinks automatically, based on the output destination.
Automatic,

/// Always embed hyperlinks, even when the output isn't going to a terminal.
Always,
}

/// Whether to show absolute paths
Expand Down Expand Up @@ -274,7 +280,7 @@ impl<C: Colours> FileName<'_, '_, C> {
classify: Classify::JustFilenames,
quote_style: QuoteStyle::QuoteSpaces,
show_icons: ShowIcons::Never,
embed_hyperlinks: EmbedHyperlinks::Off,
embed_hyperlinks: EmbedHyperlinks::Never,
is_a_tty: self.options.is_a_tty,
absolute: Absolute::Off,
};
Expand Down Expand Up @@ -415,7 +421,12 @@ impl<C: Colours> FileName<'_, '_, C> {
let mut bits = Vec::new();

let mut display_hyperlink = false;
if self.options.embed_hyperlinks == EmbedHyperlinks::On {
let should_embed_hyperlinks = match self.options.embed_hyperlinks {
EmbedHyperlinks::Never => false,
EmbedHyperlinks::Automatic => self.options.is_a_tty,
EmbedHyperlinks::Always => true,
};
if should_embed_hyperlinks {
if let Some(abs_path) = self
.file
.absolute_path()
Expand Down