Overview
List uses two visual systems:- Colors: ANSI terminal color codes that colorize file names based on type
- Icons: Emoji icons that appear before file names
Sources/SwiftListCore/Utilities/TerminalColors.swiftSources/SwiftListCore/Models/FileRepresentation.swiftSources/SwiftListCore/Utilities/FileManagerHelper.swift:32-59
Color System
Enable colors with the--color flag:
Color Mappings
List uses the following ANSI color scheme:| File Type | Color | ANSI Code | Use Case |
|---|---|---|---|
| Directories | Blue | \u{001B}[0;34m | Folders and directory paths |
| Symbolic Links | Yellow | \u{001B}[0;33m | Links pointing to other files/dirs |
| Executables | Red | \u{001B}[0;31m | Files with executable permissions |
| Regular Files | White | \u{001B}[0;37m | All other files |
Sources/SwiftListCore/Utilities/TerminalColors.swift:14-28
Colors are rendered using ANSI escape codes and will appear correctly in most modern terminals. The reset code
\u{001B}[0;0m is automatically appended after each file name to restore default colors.Color Examples
Icon System
Enable icons with the--icons flag:
Icon Mappings
List uses emoji icons to represent file types:| File Type | Icon | Description |
|---|---|---|
| Directories | π | Folders containing other files |
| Regular Files | π | Standard files (text, data, etc.) |
| Symbolic Links | π | Links pointing to other files/directories |
| Executables | βοΈ | Files with executable permissions |
Sources/SwiftListCore/Utilities/FileManagerHelper.swift:40-58
Icon Examples
Combining Colors and Icons
For maximum visual clarity, use both colors and icons together:Combined with Long Format
File Type Detection
List determines file types using the following logic (in order):-
Directories: Detected via
URL.hasDirectoryPath- Icon: π
- Color: Blue
-
Symbolic Links: Detected via file attribute
.type == .typeSymbolicLink- Icon: π
- Color: Yellow
- Shows destination path with
->separator
-
Executables: Detected via
FileManager.isExecutableFile(atPath:)- Icon: βοΈ
- Color: Red
- Must have executable permissions
-
Regular Files: Everything else
- Icon: π
- Color: White
Sources/SwiftListCore/Utilities/FileManagerHelper.swift:37-59
Symbolic links are checked before executables. This means a symbolic link to an executable file will be displayed as a link (π, yellow) rather than an executable (βοΈ, red).
Programmatic Usage
When using List as a Swift library:Direct File Type Detection
You can also use the file type detection directly:Sources/SwiftListCore/Utilities/FileManagerHelper.swift:32-59
Symbolic Link Handling
Symbolic links receive special treatment:- The link itself is displayed (not the target)
- The destination path is shown after
-> - The linkβs icon and color are used (not the targetβs)
Sources/SwiftListCore/Utilities/FileManagerHelper.swift:45-51
Terminal Compatibility
Color Support: Colors work in any terminal that supports ANSI escape codes. This includes:
- macOS Terminal.app
- iTerm2
- Most Linux terminals (GNOME Terminal, Konsole, etc.)
- Windows Terminal
- VS Code integrated terminal
Icon Support: Icons require a terminal with Unicode/emoji support and a font that includes emoji glyphs. Most modern terminals support this by default.
Tips
Related
- Display Options - All configuration options
- Sorting - Control file ordering