7 ms·
Colorls – A Ruby script that beautifies the terminal's ls command
- rangibaby 9y agols -G will get you colors in macOS. I'm sure a lot of people will like the icons but they're not for me. Around last year I got burned out on things nagging for my attention by bouncing, booping, turning red, popping up a pretty picture. Turning off all notifications on my phone was a good first step. おまけ: Here is the "ultimate" OSX ls that I found on the internet some time ago: alias l="ls -aeGhlO@" Of course that is too much information sometimes, so I kept a vanilla ls too: alias ls="ls -aG"
- klibertp 9y agoWith ls from GNU coreutils (ie. on Linux) you can get colored output with `--color=auto`. An alias for `ls` with this option is frequently already there in the systemwide .bashrc or equivalent. Personally, I use something like this: alias ls='/bin/ls -hlFA --color=auto' which also displays `/` at the end of dirs, `*` for executables and so on.
- helloman2 9y agoGNU/Linux
- klibertp 9y agoYou know, I could have written something like "On Linux you can get colored output from `ls` command ..." etc. without ever mentioning GNU at all. I went out of my way to say "GNU coreutils" (also because it's possible to install these tools on Mac and other *nixes) and you're still unsatisfied? Sorry, but that looks like you're being overly pedantic for no good reason.
- sho 9y ago> おまけ: Me speaka the 和語 too, but no need to show off. Just say "bonus:", it's an english language site. That said, thanks for the tips!
- ape4 9y agoicons are new and cool. I'd like to see that added (as an option) to regular ls.
- nurb 9y agoYou can get the same behavior on regular ls using LS_COLORS environment variable like this: export LS_COLORS='di=01;34m \033' this is only for directories but... you got the idea.
- proaralyst 9y agoI don't understand the very tricked out shells people have. Surely all those colours and bits of information are just noise that distracts over a longer shell session?
- transientbug 9y agoI tend to feel the same way but then again I have a fair amount of information that can show up in my prompt, the difference however being that it is all black against a black background so the only time I see it is if I highlight a line. Works out well for having an information dense prompt but keeping the distractions and noise lower.
- KirinDave 9y agoThere are lots of folks here for which the shell interface is usefull, but difficult to use. Using colors and graphics can be super helpful for folks with dyslexia, along with asymmetric fonts (thing I learned this year: comic sans scores incredibly well as a font for people with dyslexia). So don't poke fun. I don't have that problem, but I don't see any problem including redundancy. I have come to like Powerline-hs's git support because even if I only half-glimpse a window I immediately know the status of the repo from it just by the colors. I don't see why I wouldn't want to maximize the channels of information coming back to me.
- proaralyst 9y agoI'm not arguing for a monochrome shell with no information; my current prompt is: [user@hostname:path](git branch)$ There are colours highlighting these sections. What I'm referring to is the multi-line prompts with dates, times, uptimes etc that surely just clutter up the history view?
- cytzol 9y agoI absolutely love having a colourful shell -- assuming that each program doesn’t end up competing for your attention! I’m far more likely to notice an error if it’s red, or a warning if it’s yellow, as I find out about them subconsciously without having to read each line. However, if every program has a different idea of what an “error” is, then I’m just going to start ignoring red lines instead.
- throwaway2016a 9y agoSlightly off topic but: I was trying to figure out how he got a github icon in there then found out it uses: https://github.com/ryanoasis/nerd-fonts https://github.com/ryanoasis/nerd-fonts Very cool. Definitely using this for some of my CLI tools.
- spork12 9y agoWhat is the speed like? Ruby isn't exactly known for being the fastest.
- alekratz 9y agodisclaimer: I'm not using the fonts, but it attempts to render them anyway. Here's what `time ls` and `time lc` produced, in a directory with 517 files: > ls --color=tty -l 0.01s user 0.00s system 93% cpu 0.007 total > ~/.gem/ruby/2.4.0/bin/lc 0.14s user 0.01s system 98% cpu 0.159 total It's definitely noticeable, especially if you use `ls` day-in, day-out. But it's nothing debilitating.
- pmontra 9y agoProbably it could be made faster by working a little with InstructionSequence https://ruby-doc.org/core-2.4.1/RubyVM/InstructionSequence.html https://ruby-doc.org/core-2.4.1/RubyVM/InstructionSequence.h... and creating a "compiled" file to save the parsing time. I played with it on the day they released Ruby 2.3. It's not meant for distributing code across machines and it could fail on the same machine after some updates. It's probably not worth it to shave 152 ms on an interactive command.
- xanderstrike 9y agoThe fonts don't seem to matter. This thing is super cool but I disagree that it's not debilitating. `ls` on my home directory takes 0.005 real, `colorls` takes 0.554 real. Over 100x as long and it's an extremely noticeable half second.
- mnarayan01 9y agoSince you're presumably intending to at least glance at all the output, it's hard to imagine speed being a limiting factor here. Also internal bookkeeping done by the terminal is probably going to limit how much command speed matter, e.g. word/line wrapping: https://stackoverflow.com/questions/21947452/why-is-printing-b-dramatically-slower-than-printing https://stackoverflow.com/questions/21947452/why-is-printing...
- gbrown_ 9y agoEw way too much noise for my liking. Having said that I did use k[1] in the past. I prefer a more minimal setup these days. https://github.com/supercrabtree/k https://github.com/supercrabtree/k
- alekratz 9y agoThis looks really, REALLY cool. But as someone who lives in the terminal, it's not something I would use at all. To me, the fancy fontawesome glyphs PLUS the colors are information overload [1]. It really feels like overkill. I'm not trying to discourage anyone (including the author) from writing these things, and clearly the author is a very good programmer. If it was an exercise in making something beautiful in the terminal, then the author succeeded in this endeavor. Making a good looking, consistent terminal UI is ridiculously difficult, and each column is pretty and formatted. This program feels like it has had a lot of TLC. Honestly, I hope the author continues to make cool programs in the terminal; they clearly have a knack for it :) As a minor aside, maybe consider changing the executable name from `lc` to something else; it conflicts with the `lc` executable for Mono (at least on Arch[2], and Ubuntu[3]). But that's just a minor nitpick. [1] this is my opinion, I want to make this as clear as possible [2] https://www.archlinux.org/packages/extra/i686/mono/files/ https://www.archlinux.org/packages/extra/i686/mono/files/ [3] http://manpages.ubuntu.com/manpages/trusty/man1/lc.1.html http://manpages.ubuntu.com/manpages/trusty/man1/lc.1.html
- athityakumar 9y agoAcknowledged. The executable has been renamed to `colorls`, which can optionally be aliased in the shell configuration file. :-)
- ams6110 9y agocolorls is already in use, at least on OpenBSD it's a package that provides colorized output for ls (though not to the extent of this effort).
- velobro 9y agoThis is perfect for someone like my who's entire terminal existence is comprise of avoiding user the Finder as much as humanly possible.
- hoverbear 9y agoI've been using https://the.exa.website/ https://the.exa.website/ and it works fairly decently. Does the same coloring and tells you git status. Doesn't do icons though.
- cytzol 9y agoOf course someone links to exa right as I accidentally upload a broken linux version... of course!
- sophiedeziel 9y agoBeautiful!!!
- distantsounds 9y agoI've been accustomed to using trapd00r's LS_COLORS[1]. It differentiates the colors by file types enough to make it useful, without being overly distracting. And doesn't require installing ruby. :) [1] https://github.com/trapd00r/LS_COLORS https://github.com/trapd00r/LS_COLORS
- lionyo 9y agoThanks! This is great, works with oh-my-zsh
- eddieh 9y agoOn macOS I have this in my .profile: alias ls="ls -GF" export LSCOLORS="Exfxcxdxbxegedabagacad" -G Enables colorized output -F Display a slash (`/') immediately after each pathname that is a directory, an asterisk (`*') after each that is executable, an at sign (`@') after each symbolic link, an equals sign (`=') after each socket, a percent sign (`%') after each whiteout, and a vertical bar (`|') after each that is a FIFO. The filename/dirname is colored and the character denoting the type is not colored, so I can tell what is part of a name and what denotes the file type.
- gkya 9y agoOh my god colours. I'm an emacs user who uses shell mostly in shell-mode (i.e. a dumb shell, no curses), and dealing with these colourful commands is so annoying. Developers, please check what $TERM is like, and if it's "dumb", don't print coloured output. Main offenders for me: Ruby stuff, the new apt(8) on Ubuntu. That aside, this is not my cup of tea (I prefer dired, and don't mind the lack of icons, tho they might've been a nice ornament), but yet it looks nice, kudos. But colour me not if [ x$TERM = xdumb ].
- eridius 9y agoBetter yet, use the proper terminfo-aware routines for printing colors instead of just emitting raw ANSI escapes.
- eddieh 9y agoI agree, more stuff should work with $TERM=dumb, but how are you not using eshell?
- gkya 9y agoI do most of my stuff through Emacs' own facilities and don't use the shell that often, and every now and then knowing me some Bourne shell proves useful, so I stick to it, I completely forget otherwise.
- gitpusher 9y agoGood work, OP.
- Dowwie 9y agoIn the demo, is that a Powerline status, solarized palette?
- garethadams 9y agoLet's check the first paragraph of the readme… > Here are the screenshots of working example on an iTerm2 terminal (Mac OS), oh-my-zsh with powerlevel9k theme and powerline nerd-font + awesome-config font with the Solarized Dark color theme.
- z1mm32m4n 9y agoAnother solution to the problem of coloring `ls` output is to use the `dircolors` command, which configures the colors `ls` uses in it's output. Piggybacking on `ls` has other benefits: if you change `ls` colors, it'll get picked up by other programs, for example zsh auto-complete and the `tree` command, among others. For those interested, there are pre-existing dircolors config files that people have shared, like dircolors-solarized[1]. Of course, the OP's program does more than just ls, in that it has icons and a `--report` flag. [1]: https://github.com/seebi/dircolors-solarized https://github.com/seebi/dircolors-solarized
- michaelmior 9y agoIf you like this, check out even-better-ls[0]. It does pretty much the same thing but does it just by setting LS_COLORS, so no need to run a separate script. I also find the spacing it uses much nicer. [0] https://github.com/illinoisjackson/even-better-ls https://github.com/illinoisjackson/even-better-ls
- pixelbeat__ 9y agoInteresting use of icons. Personally I find many different colors confusing. I've a wrapper script that highlights permissions etc. rather than using colors to distinguish them. It also makes the output of ls consistent across linux/osx/solaris/... which it does by adjusting the output from the existing ls implementations on each platform http://www.pixelbeat.org/scripts/l http://www.pixelbeat.org/scripts/l
- auxym 9y agoIt looks like this uses the github logo for the .git folder. Why not the git-scm logo? https://git-scm.com/images/logo@2x.png https://git-scm.com/images/logo@2x.png
- athityakumar 9y agoSadly, the font icon seems too tiny when used on the terminal. Only the GitHub logo seems easily viewable. Feel free to share your thoughts here : https://github.com/athityakumar/colorls/issues/33 https://github.com/athityakumar/colorls/issues/33