A more colorful, user-friendly implementation of ls written in Go.
You want to be able to glean a lot of information as quickly as possible from ls.
Colors can help your mind parse the information.
You can configure ls to color the output a little bit.
Configuring ls is a hassle though, and the colors are limited.
Instead, you can use ls-go.
It is highly colored by default.
It has much fewer flags so you can get the behavior you want more easily.
The colors are beautiful and semantic.
A terminal with xterm-256 colors is required.
- Works on Linux, Mac OS X, Windows, FreeBSD and most popular Unix-like systems.
- Outputs beautiful, semantic colors by default.
- Show paths to symlinks, and explicitly show broken links.
- Recurse down sub-directories.
- Emojis (if you're into that) and Nerd Fonts.
- Supports producing structured JSON and CSV output (to use with jq or similar tools).
- Full flexibility in choosing which columns / information to show.
- Support correct handling of CJK and other wide or invisible Unicode characters in tabular format.
- Better default sorting (by basename then extension) and 8 custom sorting methods (more than
ls, although lacking a few oflssorting methods). - Support several formats for time and file sizes, along with custom Unix's time format and Go's time format.
- High compatibility with
lscommand's flags.
ls-go works with Nerd Fonts.
Simply add --nerd-font or -n to get file-specific icons.
This won't work unless you have a Nerd Font installed and selected in your terminal emulator.
Run go install github.com/ilius/ls-go@latest. Or clone the repository and run go install within ls-go directory.
This is inspired by athityakumar/colorls and monsterkodi/color-ls, ported to Go, with various modifications.
It fails on directories without executable permissions.
The standard /bin/ls will also fail when reading non-executable directories,
but only with certain options, like ls -l, ls --color=always (or ls -G on MacOS).
This is because file metadata is needed to determine things like colors,
and directories need to be executable to obtain the metadata of the contents.
For example:
# create dir without -x permission
$ mkdir -m 644 test
# add a file
$ sudo touch test/foo
# plain `ls` still works
$ /bin/ls test
foo
# but `ls -l` fails
$ /bin/ls -l test
# and so does ls-go
$ ls-go testContributions are muchly appreciated! Want to add a glyph for another file type? Did I forget an edge case? Is there another option that would be useful? Submit a PR! You might want to submit an issue first to make sure it's something I'd want to add though.
Do not ignore entries starting with .
Do not list implied . and ..
By default, files / directories are sorted by basename (name without extension) then by extension (this is different than sorting by name).
Use this flag to sort by given column.
Supported values:
nonename: sort by full file name (basename and extension)basename: sort by base name (name without extension)size: sort by file or directory sizefilesize: sort by file size onlytimeextensionkindinodelinks: sort by number of hard linksmode(numeric file mode, includes permissions and file type)name-len: length of file name
Print the size of each file.
With -l or -s / --size, print sizes like 1K, 234M, 2G, etc.
Use metric system for size. Like --human-readable, but use powers of 1000, not 1024.
Print sizes in bytes.
Show allocated number of blocks (like ls -s) as a new column.
Change the default of using modification times (mtime).
- Access time:
atime,access,use - Change time:
ctime,status,change
With -l, it determines which time to show.
With --sort=time, sorts by given time (newest first).
Time/date format with -l.
Can set environment variable LSGO_TIME_STYLE to use as default (except for --json).
Supported time styles:
-
full-isoorfull- Go format:
2006-01-02 15:04:05.999999999 Z0700 - Unix format:
%Y-%m-%d %H:%M:%S.%N %z
- Go format:
-
long-isoorlong- Go format:
2006-01-02 15:04 - Unix format:
%Y-%m-%d %H:%M
- Go format:
-
iso- Go format:
01-02 15:04 - Unix format:
%m-%d %H:%M
- Go format:
-
relativeorrel- Show relative to current time, for example "1 day, 21:24:23 ago"
-
+sign followed by a Unix time format (seeman dateor this link)
Shortcut to -l --time-style=full-iso.
Include modification time (of file contents).
Include change time (of file contents or metadata).
Include access time.
Include owner and group.
Show group (without long mode).
Hide group name (with -l).
Like -l, but list numeric user and group IDs.
Include permissions for owner, group, and other.
Include permissions / mode in octal format.
Print the index number (inode number) of each file.
Include size, date, owner, and permissions.
Include all columns.
Show one file per line.
List entries by lines instead of by columns.
List entries by columns.
Try to fit more columns in many-files-per-line modes (vertical/horizontal).
Show vertical bars between files in a row, or between columns in --long or --oneline mode.
Use given quoting style for entry names.
This overrides QUOTING_STYLE environment variable.
Supported values:
literalshellshell-alwaysshell-escapeshell-escape-alwayscescapenone
Shortcut to --quoting-style=literal.
Print entry names without quoting.
Shortcut to --quoting-style=escape.
Print C-style escapes for nongraphic characters.
List directories themselves, not their contents.
Show directories before files.
Only show directories.
Only show files.
Only show items with mode(permissions) that contains the given octal mode.
When showing file information for a symbolic link, show information for the file the link references rather than for the link itself.
Show paths for symlinks.
Show symlinks as relative paths if shorter than absolute path.
Reverse order while sorting.
Show statistics.
Show folder icon before directory name.
Show nerd font glyphs before file names.
Traverse all directories recursively.
Filter items with a regexp.
Accepted values:
--color=always,--color=yes,--color=y,--color=--color=never,--color=no,--color=n--color=auto(default): enables colors only when stdout is connected to a terminal
Whether or not to colorize the output.
auto means if stdout connected to a terminal.
Add a header line with:
-lor--long-1or--oneline--json--json-array(shows header by default)--csv(shows header by default)
Do not add a header line with --csv or --json-array.
Print JSON-encoded lines instead of tables (one object per line).
Print JSON-encoded lines instead of tables, one array per line.
With --json and --json-array, escape Unicode characters and ensure output is ASCII.
In tabular/normal mode, apply this only to file names.
Print a CSV table.
Print HTML.
Read JSON-encoded lines from stdin, instead of looking at filesystem and path arguments.
Example usage with jq:
ls-go -l --json | jq -cM 'select(.size > 5000)' | ls-go -l --read-json
which is equivalent to
ls-go -l --where 'size > 5000'
Minimum file size (in bytes).
Maximum file size (in bytes).
Shortcut to --sort=time.
Sort by time, newest first.
See --time.
Shortcut to --time=ctime.
With -lt: sort by, and show, ctime (time of last modification of file status information).
With -l: show ctime and sort by name.
Otherwise: sort by ctime, newest first.
Shortcut to --time=use.
With -lt: sort by, and show, access time.
With -l: show access time and sort by name.
Otherwise: sort by access time, newest first.
Shortcut to --sort=none.
Do not sort (list entries in directory order).
Shortcut to --sort=size.
Sort by file size, largest first.
Shortcut to --sort=extension.
Sort alphabetically by entry extension.
Print colors in json format and exit.
Show help in markdown format.
Show usage message.
Show version.