mirror of
https://github.com/eza-community/eza
synced 2024-10-04 15:09:49 +00:00
feat: show directories last
This feature lists directories after all other entries in a directory. This is convenient when combined with the tree-view.
This commit is contained in:
parent
22dbeec229
commit
92471941c4
|
@ -108,6 +108,7 @@ eza’s options are almost, but not quite, entirely unlike `ls`’s. Quick overv
|
||||||
- **-r**, **--reverse**: reverse the sort order
|
- **-r**, **--reverse**: reverse the sort order
|
||||||
- **-s**, **--sort=(field)**: which field to sort by
|
- **-s**, **--sort=(field)**: which field to sort by
|
||||||
- **--group-directories-first**: list directories before other files
|
- **--group-directories-first**: list directories before other files
|
||||||
|
- **--group-directories-last**: list directories after other files
|
||||||
- **-D**, **--only-dirs**: list only directories
|
- **-D**, **--only-dirs**: list only directories
|
||||||
- **-f**, **--only-files**: list only files
|
- **-f**, **--only-files**: list only files
|
||||||
- **--git-ignore**: ignore files mentioned in `.gitignore`
|
- **--git-ignore**: ignore files mentioned in `.gitignore`
|
||||||
|
|
|
@ -47,6 +47,7 @@ complete -c eza -l smart-group -d "Only show group if it has a different name fr
|
||||||
|
|
||||||
# Filtering and sorting options
|
# Filtering and sorting options
|
||||||
complete -c eza -l group-directories-first -d "Sort directories before other files"
|
complete -c eza -l group-directories-first -d "Sort directories before other files"
|
||||||
|
complete -c eza -l group-directories-last -d "Sort directories after other files"
|
||||||
complete -c eza -l git-ignore -d "Ignore files mentioned in '.gitignore'"
|
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. Use this twice to also show the '.' and '..' directories"
|
complete -c eza -s a -l all -d "Show hidden and 'dot' files. Use this twice to also show the '.' and '..' directories"
|
||||||
complete -c eza -s A -l almost-all -d "Equivalent to --all; included for compatibility with `ls -A`"
|
complete -c eza -s A -l almost-all -d "Equivalent to --all; included for compatibility with `ls -A`"
|
||||||
|
|
|
@ -20,6 +20,7 @@ export extern "eza" [
|
||||||
--hyperlink # Display entries as hyperlinks
|
--hyperlink # Display entries as hyperlinks
|
||||||
--absolute # Display entries with their absolute path
|
--absolute # Display entries with their absolute path
|
||||||
--group-directories-first # Sort directories before other files
|
--group-directories-first # Sort directories before other files
|
||||||
|
--group-directories-last # Sort directories after other files
|
||||||
--git-ignore # Ignore files mentioned in '.gitignore'
|
--git-ignore # Ignore files mentioned in '.gitignore'
|
||||||
--all(-a) # Show hidden and 'dot' files. Use this twice to also show the '.' and '..' directories
|
--all(-a) # Show hidden and 'dot' files. Use this twice to also show the '.' and '..' directories
|
||||||
--almost-all(-A) # Equivalent to --all; included for compatibility with `ls -A`
|
--almost-all(-A) # Equivalent to --all; included for compatibility with `ls -A`
|
||||||
|
|
|
@ -28,6 +28,7 @@ __eza() {
|
||||||
--hyperlink"[Display entries as hyperlinks]" \
|
--hyperlink"[Display entries as hyperlinks]" \
|
||||||
--absolute"[Display entries with their absolute path]:(mode):(on follow off)" \
|
--absolute"[Display entries with their absolute path]:(mode):(on follow off)" \
|
||||||
--group-directories-first"[Sort directories before other files]" \
|
--group-directories-first"[Sort directories before other files]" \
|
||||||
|
--group-directories-last"[Sort directories after other files]" \
|
||||||
--git-ignore"[Ignore files mentioned in '.gitignore']" \
|
--git-ignore"[Ignore files mentioned in '.gitignore']" \
|
||||||
{-a,--all}"[Show hidden and 'dot' files. Use this twice to also show the '.' and '..' directories]" \
|
{-a,--all}"[Show hidden and 'dot' files. Use this twice to also show the '.' and '..' directories]" \
|
||||||
{-A,--almost-all}"[Equivalent to --all; included for compatibility with \'ls -A\']" \
|
{-A,--almost-all}"[Equivalent to --all; included for compatibility with \'ls -A\']" \
|
||||||
|
|
|
@ -160,6 +160,9 @@ Sort fields starting with a capital letter will sort uppercase before lowercase:
|
||||||
`--group-directories-first`
|
`--group-directories-first`
|
||||||
: List directories before other files.
|
: List directories before other files.
|
||||||
|
|
||||||
|
`--group-directories-last`
|
||||||
|
: List directories after other files.
|
||||||
|
|
||||||
`-D`, `--only-dirs`
|
`-D`, `--only-dirs`
|
||||||
: List only directories, not files.
|
: List only directories, not files.
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,8 @@ commands:
|
||||||
- type
|
- type
|
||||||
? - null
|
? - null
|
||||||
- --group-directories-first
|
- --group-directories-first
|
||||||
|
? - null
|
||||||
|
- --group-directories-last
|
||||||
? - -D
|
? - -D
|
||||||
- --only-dirs
|
- --only-dirs
|
||||||
? - -f
|
? - -f
|
||||||
|
|
|
@ -43,6 +43,10 @@ pub struct FileFilter {
|
||||||
/// second. Some users prefer it like this.
|
/// second. Some users prefer it like this.
|
||||||
pub list_dirs_first: bool,
|
pub list_dirs_first: bool,
|
||||||
|
|
||||||
|
/// Whether directories should be listed as the last items, after other
|
||||||
|
/// types of file. Some users prefer it like this.
|
||||||
|
pub list_dirs_last: bool,
|
||||||
|
|
||||||
/// The metadata field to sort by.
|
/// The metadata field to sort by.
|
||||||
pub sort_field: SortField,
|
pub sort_field: SortField,
|
||||||
|
|
||||||
|
@ -126,6 +130,12 @@ impl FileFilter {
|
||||||
.points_to_directory()
|
.points_to_directory()
|
||||||
.cmp(&a.as_ref().points_to_directory())
|
.cmp(&a.as_ref().points_to_directory())
|
||||||
});
|
});
|
||||||
|
} else if self.list_dirs_last {
|
||||||
|
files.sort_by(|a, b| {
|
||||||
|
a.as_ref()
|
||||||
|
.points_to_directory()
|
||||||
|
.cmp(&b.as_ref().points_to_directory())
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ impl FileFilter {
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
return Ok(Self {
|
return Ok(Self {
|
||||||
list_dirs_first: matches.has(&flags::DIRS_FIRST)?,
|
list_dirs_first: matches.has(&flags::DIRS_FIRST)?,
|
||||||
|
list_dirs_last: matches.has(&flags::DIRS_LAST)?,
|
||||||
flags: filter_flags,
|
flags: filter_flags,
|
||||||
sort_field: SortField::deduce(matches)?,
|
sort_field: SortField::deduce(matches)?,
|
||||||
dot_filter: DotFilter::deduce(matches)?,
|
dot_filter: DotFilter::deduce(matches)?,
|
||||||
|
|
|
@ -39,6 +39,7 @@ pub static SORT: Arg = Arg { short: Some(b's'), long: "sort", take
|
||||||
pub static IGNORE_GLOB: Arg = Arg { short: Some(b'I'), long: "ignore-glob", takes_value: TakesValue::Necessary(None) };
|
pub static IGNORE_GLOB: Arg = Arg { short: Some(b'I'), long: "ignore-glob", takes_value: TakesValue::Necessary(None) };
|
||||||
pub static GIT_IGNORE: Arg = Arg { short: None, long: "git-ignore", takes_value: TakesValue::Forbidden };
|
pub static GIT_IGNORE: Arg = Arg { short: None, long: "git-ignore", takes_value: TakesValue::Forbidden };
|
||||||
pub static DIRS_FIRST: Arg = Arg { short: None, long: "group-directories-first", takes_value: TakesValue::Forbidden };
|
pub static DIRS_FIRST: Arg = Arg { short: None, long: "group-directories-first", takes_value: TakesValue::Forbidden };
|
||||||
|
pub static DIRS_LAST: Arg = Arg { short: None, long: "group-directories-last", takes_value: TakesValue::Forbidden };
|
||||||
pub static ONLY_DIRS: Arg = Arg { short: Some(b'D'), long: "only-dirs", takes_value: TakesValue::Forbidden };
|
pub static ONLY_DIRS: Arg = Arg { short: Some(b'D'), long: "only-dirs", takes_value: TakesValue::Forbidden };
|
||||||
pub static ONLY_FILES: Arg = Arg { short: Some(b'f'), long: "only-files", takes_value: TakesValue::Forbidden };
|
pub static ONLY_FILES: Arg = Arg { short: Some(b'f'), long: "only-files", takes_value: TakesValue::Forbidden };
|
||||||
const SORTS: Values = &[ "name", "Name", "size", "extension",
|
const SORTS: Values = &[ "name", "Name", "size", "extension",
|
||||||
|
@ -92,7 +93,7 @@ pub static ALL_ARGS: Args = Args(&[
|
||||||
&COLOR, &COLOUR, &COLOR_SCALE, &COLOUR_SCALE, &COLOR_SCALE_MODE, &COLOUR_SCALE_MODE,
|
&COLOR, &COLOUR, &COLOR_SCALE, &COLOUR_SCALE, &COLOR_SCALE_MODE, &COLOUR_SCALE_MODE,
|
||||||
&WIDTH, &NO_QUOTES, &ABSOLUTE,
|
&WIDTH, &NO_QUOTES, &ABSOLUTE,
|
||||||
|
|
||||||
&ALL, &ALMOST_ALL, &LIST_DIRS, &LEVEL, &REVERSE, &SORT, &DIRS_FIRST,
|
&ALL, &ALMOST_ALL, &LIST_DIRS, &LEVEL, &REVERSE, &SORT, &DIRS_FIRST, &DIRS_LAST,
|
||||||
&IGNORE_GLOB, &GIT_IGNORE, &ONLY_DIRS, &ONLY_FILES,
|
&IGNORE_GLOB, &GIT_IGNORE, &ONLY_DIRS, &ONLY_FILES,
|
||||||
|
|
||||||
&BINARY, &BYTES, &GROUP, &NUMERIC, &HEADER, &ICONS, &INODE, &LINKS, &MODIFIED, &CHANGED,
|
&BINARY, &BYTES, &GROUP, &NUMERIC, &HEADER, &ICONS, &INODE, &LINKS, &MODIFIED, &CHANGED,
|
||||||
|
|
|
@ -39,6 +39,7 @@ FILTERING AND SORTING OPTIONS
|
||||||
-r, --reverse reverse the sort order
|
-r, --reverse reverse the sort order
|
||||||
-s, --sort SORT_FIELD which field to sort by
|
-s, --sort SORT_FIELD which field to sort by
|
||||||
--group-directories-first list directories before other files
|
--group-directories-first list directories before other files
|
||||||
|
--group-directories-last list directories after other files
|
||||||
-D, --only-dirs list only directories
|
-D, --only-dirs list only directories
|
||||||
-f, --only-files list only files
|
-f, --only-files list only files
|
||||||
-I, --ignore-glob GLOBS glob patterns (pipe-separated) of files to ignore";
|
-I, --ignore-glob GLOBS glob patterns (pipe-separated) of files to ignore";
|
||||||
|
|
Loading…
Reference in a new issue