GithubHelp home page GithubHelp logo

acarl005 / ls-go Goto Github PK

View Code? Open in Web Editor NEW
219.0 4.0 25.0 2.77 MB

A more colorful, user-friendly implementation of `ls` written in Go

License: MIT License

Go 98.49% Shell 1.51%
go command-line terminal ansi-colors

ls-go's Introduction

ls-go

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.

Features

  • Should work on Linux, MacOS, and Windows.
  • Outputs beautiful, semantic colors by default.
  • Show paths to symlinks, and explicitly show broken links (-L).
  • Recurse down subdirectories (-r).
  • Emojis, if you're into that (-i).
  • Supports Nerd Fonts (-n).
  • Dark or light backgrounds (-I).

Usage

Basic usage:

show basic usage

Of course, you can use an alias to save some typing and get your favorite options:

show fancier options

Nerd Font Support

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.

show with nerd font icons

Light Background Theme

Has an option for white backgrounds.

show on white background

usage: ls-go [<flags>] [<paths>...]

Flags:
  -h, --help       Show context-sensitive help (also try --help-long and --help-man).
  -a, --all        show hidden files
  -b, --bytes      include size
  -m, --mdate      include modification date
  -o, --owner      include owner and group
  -N, --nogroup    hide group
  -p, --perms      include permissions for owner, group, and other
  -l, --long       include size, date, owner, and permissions
  -d, --dirs       only show directories
  -f, --files      only show files
  -L, --links      show paths for symlinks
  -R, --link-rel   show symlinks as relative paths if shorter than absolute path
  -s, --size       sort items by size
  -t, --time       sort items by time
  -k, --kind       sort items by extension
  -B, --backwards  reverse the sort order of --size, --time, or --kind
  -S, --stats      show statistics
  -i, --icons      show folder icon before dirs
  -n, --nerd-font  show nerd font glyphs before file names
  -r, --recurse    traverse all dirs recursively
  -F, --find=FIND  filter items with a regexp
  -I, --light      output colors for light-bachground themes

Args:
  [<paths>]  the files(s) and/or folder(s) to display

Install

If you have Golang installed:

go install github.com/acarl005/ls-go@latest

On MacOS with Homebrew:

brew install acarl005/homebrew-formulas/ls-go

On Linux with Snap:

sudo snap install ls-go

Or, you can download the latest pre-compiled binary from the releases page.

Credits

Warp Terminal logo

Screenshots taken using Warp Terminal.

This is inspired by athityakumar/colorls and monsterkodi/color-ls, ported to Go, with various modifications.

Known Issues

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 test

Contributing

Contributions 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.

ls-go's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ls-go's Issues

Feature requests

Hello, I really love this tool, but there are a couple of things that would increase my pleasure even more!

  1. Is it possible, when using the --nerd-font, to optionally specify that an extra space be displayed between the nerdchar and the file/folder name?
  2. Is it possible to specify a hidden files ONLY option?

It may be that ls-go already supports these options and I just haven't found them yet.
Alternatively, I guess I could just fork the Golang code. Hmm... there's an idea!

suggestion - add reverse sort order option

I often use the reverse sorting option with ls, particularly when sorting by time. I am not sure what flags would be appropriate here since -r and -R are already in use.

autocomplete dirs in warp

It seems that in Warp terminal I cant autocomplete tabs through TAB button. Maybe I shoud add something to my configuration?

panic: user: unknown userid

Panics when encountering a file or directory where there is no user mapping. Presumably the same will happen for non-mapped groups.

uname -a
Linux laptop 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u5 (2017-09-19) x86_64 GNU/Linux
go version
go version go1.9 linux/amd64
v0.0.2 
nicolaw@laptop: ~/go/src/github.com/acarl005/ls-go $ git rev-parse HEAD 
187bc787f33b3c1a82f68d3b3de205f3a26e79b9
panic: user: unknown userid 999

goroutine 1 [running]:
main.check(0x74c0e0, 0xc420390508)
	/home/nicolaw/go/src/github.com/acarl005/ls-go/ls-go.go:603 +0x4a
main.getOwnerAndGroup(0xc42004f9d8, 0xc420019304, 0x7, 0xc4203904f0, 0x7)
	/home/nicolaw/go/src/github.com/acarl005/ls-go/ls-unix.go:22 +0x18e
main.listFiles(0xc42038e640, 0x15, 0xc42004fbe8, 0x0)
	/home/nicolaw/go/src/github.com/acarl005/ls-go/ls-go.go:147 +0x1a8
main.listDir(0xc42038e640, 0x15)
	/home/nicolaw/go/src/github.com/acarl005/ls-go/ls-go.go:121 +0x31e
main.listDir(0xc4204c45c0, 0xb)
	/home/nicolaw/go/src/github.com/acarl005/ls-go/ls-go.go:128 +0x2d9
main.listDir(0x631b44, 0x1)
	/home/nicolaw/go/src/github.com/acarl005/ls-go/ls-go.go:128 +0x2d9
main.main()
	/home/nicolaw/go/src/github.com/acarl005/ls-go/ls-go.go:86 +0x4ac

ls-go painic when file group is unkonwn

When the group is unknown, ls-go will show the error below, then panic

panic: group: unknown groupid 1000

goroutine 1 [running]:
main.check(0x63fa20, 0xc42007e830)
        /home/jiasui/repos/ls-go/src/github.com/acarl005/ls-go/ls-go.go:603 +0x4a
main.getOwnerAndGroup(0xc4200ddc30, 0x1a4, 0x0, 0x0, 0x1)
        /home/jiasui/repos/ls-go/src/github.com/acarl005/ls-go/ls-unix.go:24 +0x1b4
main.listFiles(0x619564, 0x1, 0xc4200dde38, 0x0)
        /home/jiasui/repos/ls-go/src/github.com/acarl005/ls-go/ls-go.go:189 +0x59f
main.listDir(0x619564, 0x1)
        /home/jiasui/repos/ls-go/src/github.com/acarl005/ls-go/ls-go.go:121 +0x2e8
main.main()
        /home/jiasui/repos/ls-go/src/github.com/acarl005/ls-go/ls-go.go:86 +0x45d

Reproduce step:

  1. touch 123
  2. chown jiasui:1000 123
  3. Run ls-go

Runtime errors

macOS 10.13.6
Golang 1.10.3
Git 2.13.0

Hello. I've just tried running ls-go.go with vgo run ls-go.go, but I get a bunch of errors:

# command-line-arguments
./ls-go.go:54:2: undefined: argsPostParse
./ls-go.go:59:27: undefined: args
./ls-go.go:103:10: undefined: args
./ls-go.go:106:31: undefined: args
./ls-go.go:115:12: undefined: args
./ls-go.go:116:10: undefined: args
./ls-go.go:124:6: undefined: args
./ls-go.go:126:50: undefined: args
./ls-go.go:145:6: undefined: args
./ls-go.go:147:20: undefined: getOwnerAndGroup
./ls-go.go:147:20: too many errors

What am I doing wrong? Thanks!

License?

I know this may be obvious, but is there any license to go with this?

ls with wrong argument panics

if i'm in a directory with a file named bar
if I run ls-go baz I get a panic.

panic: stat baz: no such file or directory

goroutine 1 [running]:
main.check(0x74eb40, 0xc4200112c0)
	/home/bugless/src/github.com/acarl005/ls-go/ls-go.go:478 +0x4a
main.main()
	/home/bugless/src/github.com/acarl005/ls-go/ls-go.go:59 +0x1dd

Wrong colors

Is it possible to use the default terminal colors instead of custom ones?
I have a tad different palette configured, e.g.:

  • exa

exa

  • ls-go

ls-go

Would like to embedd this in my project

Basically i am working on small modifications to my fork of Gosh
and i want to implement this into my project

I am looking for a half decent implementation of ls and other directory management utilities in go, and this one fits the bill for the most part

Permissions display incomplete (on Linux)

It appears neither sticky bit nor ACL "+" get shown when doing a directory listing:

# ls-go -l .
 d rwx rwx r-x  www-data www-data   4.00K 31.Jul'20 07:34  default

Comparing to regular ls:

# ls -l .
drwsrwsr-x+ 10 www-data www-data 4096 Jul 31 07:34 default

Not sure if ACL is possible to add. But sticky bit is pretty essential. :)

Build Issues on Windows

When trying to build on Windows, I get these errors:

# github.com/acarl005/ls-go
..\..\..\..\acarl005\ls-go\ls-windows.go:59:10: undefined: syscall.Stat_t
..\..\..\..\acarl005\ls-go\ls-windows.go:60:9: undefined: syscall.Stat
..\..\..\..\acarl005\ls-go\ls-windows.go:62:35: undefined: "golang.org/x/sys/windows".Major
..\..\..\..\acarl005\ls-go\ls-windows.go:63:35: undefined: "golang.org/x/sys/windows".Minor

It seems that syscall.Stat_t is only available on Linux systems, and I'm not sure when windows.Major/Minor was deprecated...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.