DisplayOptions struct controls how files are displayed, sorted, and formatted when listing directory contents.
Type Definition
SwiftListCore/Configuration/DisplayOptions.swift
Properties
The location to list files from. If
nil, uses the current working directory.Whether to show hidden files (files starting with
.).Whether to use long listing format, which displays detailed information including permissions, owner, group, link count, size, and modification date.
Whether to recurse into subdirectories. When enabled, lists contents of all subdirectories.
Whether to colorize the output using ANSI color codes. Different file types are displayed in different colors.
Whether to show file type icons (emoji) before file names. Uses 📁 for directories, 📄 for files, 🔗 for symbolic links, and ⚙️ for executables.
Whether to display one file per line. Useful for scripts and parseable output.
Whether to show human-readable file sizes (e.g., “1.5 MB” instead of “1572864 bytes”). Only applies when
long is true.Whether to list directories themselves rather than their contents. When
true, shows information about the directory rather than listing what’s inside.Whether to append indicators to entries. Adds
/ to directories and * to executable files.How to sort the file listing. Options are
.name (alphabetically), .time (by modification time, newest first), or .size (by size, largest first).Maximum recursion depth when
recurse is true. nil means unlimited depth. A value of 0 means only the initial directory, 1 includes immediate subdirectories, etc.Initializer
DisplayOptions instance with only the options you need to customize.
Usage Examples
Basic Listing
Long Format with Details
Colorized with Icons
Show All Files Including Hidden
Recursive Listing with Depth Limit
Sort by Modification Time
Sort by File Size
List Specific Directory
Directory Information Only
Complete Example
Related
- FileManagerHelper - Use DisplayOptions with this class
- SortOption - Sorting options enumeration
- TerminalColors - Colors used when
coloris enabled