athityakumar / colorls Goto Github PK
View Code? Open in Web Editor NEWA Ruby gem that beautifies the terminal's ls command, with color and font-awesome icons. :tada:
License: MIT License
A Ruby gem that beautifies the terminal's ls command, with color and font-awesome icons. :tada:
License: MIT License
Personally rubs me the wrong way that Git is conflated with Github in the minds of many.
Suggest using this icon perhaps.
This flag option can be used to recursively print all files inside sub-directories.
Side note : The existing -r / --report
flag can be changed to -i / --info
.
how do i list dot files?
There're some options that works on normal /usr/bin/ls
but does not work or works differently in colorls
. Here're some (there're more in man ls
but I couldn't list them all, so I just list things I needed most):
-a
and --all
should also list .
and ..
-A
and --almost-all
should list all files except .
and ..
-l
should print a long list-lh
and -l --human-readable
should print a long list with human readable file size (in B, KB, MB, etc.)Related:
I wrote a short shellscript that works like ls -lrt
but displays the git status next to each file displayed, as shown in the [..]
here:
You could consider adding a similar feature to lsc
.
The git status of each file could be indicated either using an icon, or using color (on the icon, or on the file).
(There are other versioning systems than git, so it might be good to leave room for them in future.)
Hi. I'm trying to run this on Linux. I'm a little stuck at the install line that says "Install the patched fonts of powerline nerd-font and/or font-awesome." Can you give some better instructions?
Also, (at least on Linux) the lc
command is already taken by the Mono Licnese Compiler
if you have Mono installed. This may be an issue for some others.
Hey there, first off awesome project.
I just installed it and it look really neat !
But I happend to use it against some empty directory and I got that
uncoolshogun@tpx1:~$ mkdir test
uncoolshogun@tpx1:~$ sl test/
/var/lib/gems/2.3.0/gems/colorls-0.1.4/lib/colorls/core.rb:103:in 'in_line': undefined method '+' for nil:NilClass (NoMethodError)
from /var/lib/gems/2.3.0/gems/colorls-0.1.4/lib/colorls/core.rb:87:in 'chunkify'
from /var/lib/gems/2.3.0/gems/colorls-0.1.4/lib/colorls/core.rb:20:in 'ls'
from /var/lib/gems/2.3.0/gems/colorls-0.1.4/lib/colorls/flags.rb:23:in 'block in process'
from /var/lib/gems/2.3.0/gems/colorls-0.1.4/lib/colorls/flags.rb:21:in 'each'
from /var/lib/gems/2.3.0/gems/colorls-0.1.4/lib/colorls/flags.rb:21:in 'process'
from /var/lib/gems/2.3.0/gems/colorls-0.1.4/exe/colorls:4:in '<top (required)>'
from /usr/local/bin/colorls:23:in 'load'
from /usr/local/bin/colorls:23:in '<main>'
uncoolshogun@tpx1:~$
I am not familiar with ruby but it does look like a stack trace 😝
Is it just me ? I am on ubuntu 16.04
ps : sl is my alias for colorls ^-^
Great project, definitely snazzes up a dull terminal. I was just about to alias ls to lc when i ran into trouble once i tried this inside of a Ruby (rails) project.
It looks like it needs the colorize gem in the bundle to work and I even threw it into the gemfile to see if that works, no luck.
Here is my error:
/Users/vincent/.rbenv/versions/2.2.6/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- colorize (LoadError)
from /Users/vincent/.rbenv/versions/2.2.6/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/vincent/bin/colorls/colorls.rb:3:in `<main>'
Any idea how to fix?
Much appreciated!
When I run bundle install
I get this error:
Fetching gem metadata from https://rubygems.org/................
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 12.0.0
Using colorize 0.8.1
Using facets 3.1.0
Using parallel 1.11.2
Using ast 2.3.0
Using powerpack 0.1.1
Using ruby-progressbar 1.8.1
Using unicode-display_width 1.3.0
Fetching ruby-terminfo 0.1.1
Your user account isn't allowed to install to the system RubyGems.
You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to RubyGems using sudo.
Password:
Installing ruby-terminfo 0.1.1 with native extensions
Using bundler 1.15.1
Using rainbow 2.2.2
Using parser 2.4.0.0
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /tmp/bundler20170703-28554-15grtxbruby-terminfo-0.1.1/gems/ruby-terminfo-0.1.1
/usr/bin/ruby2.3 -r ./siteconf20170703-28554-42d6sm.rb extconf.rb
checking for setupterm() in -lncurses... no
checking for setupterm() in -lcurses... no
checking for rb_io_t in ruby.h,rubyio.h... yes
checking for rb_io_t.fd in ruby.h,rubyio.h... yes
checking for OpenFile.fd in ruby.h,rubyio.h... no
creating extconf.h
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/tmp/bundler20170703-28554-15grtxbruby-terminfo-0.1.1/extensions/x86_64-linux/2.3.0/ruby-terminfo-0.1.1/mkmf.log
current directory: /tmp/bundler20170703-28554-15grtxbruby-terminfo-0.1.1/gems/ruby-terminfo-0.1.1
make "DESTDIR=" clean
current directory: /tmp/bundler20170703-28554-15grtxbruby-terminfo-0.1.1/gems/ruby-terminfo-0.1.1
make "DESTDIR="
compiling terminfo.c
In file included from terminfo.c:33:0:
/usr/include/ruby-2.3.0/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h" [-Wcpp]
#warning use "ruby/io.h" instead of "rubyio.h"
^
terminfo.c:36:20: fatal error: curses.h: No such file or directory
compilation terminated.
Makefile:246: recipe for target 'terminfo.o' failed
make: *** [terminfo.o] Error 1
make failed, exit code 2
Gem files will remain installed in /tmp/bundler20170703-28554-15grtxbruby-terminfo-0.1.1/gems/ruby-terminfo-0.1.1 for inspection.
Results logged to /tmp/bundler20170703-28554-15grtxbruby-terminfo-0.1.1/extensions/x86_64-linux/2.3.0/ruby-terminfo-0.1.1/gem_make.out
An error occurred while installing ruby-terminfo (0.1.1), and Bundler cannot continue.
Make sure that `gem install ruby-terminfo -v '0.1.1'` succeeds before bundling.
In Gemfile:
ruby-terminfo
whe i type: sudo gem install colorls
i get:
Building native extensions. This could take a while...
ERROR: Error installing colorls:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/ruby-terminfo-0.1.1
/usr/bin/ruby2.3 -r ./siteconf20170710-21629-gq9k0b.rb extconf.rb
checking for setupterm() in -lncurses... no
checking for setupterm() in -lcurses... no
checking for rb_io_t in ruby.h,rubyio.h... yes
checking for rb_io_t.fd in ruby.h,rubyio.h... yes
checking for OpenFile.fd in ruby.h,rubyio.h... no
creating extconf.h
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/ruby-terminfo-0.1.1/mkmf.log
current directory: /var/lib/gems/2.3.0/gems/ruby-terminfo-0.1.1
make "DESTDIR=" clean
current directory: /var/lib/gems/2.3.0/gems/ruby-terminfo-0.1.1
make "DESTDIR="
compiling terminfo.c
In file included from terminfo.c:33:0:
/usr/include/ruby-2.3.0/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h" [-Wcpp]
#warning use "ruby/io.h" instead of "rubyio.h"
^~~~~~~
terminfo.c:36:20: fatal error: curses.h: Arquivo ou diretório não encontrado
#include <curses.h>
^
compilation terminated.
Makefile:246: recipe for target 'terminfo.o' failed
make: *** [terminfo.o] Error 1
make failed, exit code 2
Gem files will remain installed in /var/lib/gems/2.3.0/gems/ruby-terminfo-0.1.1 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/ruby-terminfo-0.1.1/gem_make.out
ruby version is 2.3.1, i already tried to rename the folders.
when i use "lc",it appears this /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- colorize (LoadError) from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from /Users/huangda/colorls/colorls.rb:1:in `
It's quite important to document the changes that were made in each version of the released gem.
I did install gem install colorls
.
Then I run lc
it shows the list of my files and folders with come color but the icon is not working(
).
Does anyone know what I did wrong?
I like to replace my ls with lc but its missing the option to show the target of a symlink.
like "ls -l " test.rb -> mydir/test_v1.php
Redirecting from issue #4
$ lc -a 123ms Saturday 01 July 2017 07:53:57 PM IST
colorls/colorls.rb:10:in `open': No such file or directory @ dir_initialize - -a (Errno::ENOENT)
from colorls/colorls.rb:10:in `entries'
from colorls/colorls.rb:10:in `initialize'
from colorls/colorls.rb:121:in `new'
from colorls/colorls.rb:121:in `block in <main>'
from colorls/colorls.rb:121:in `each'
from colorls/colorls.rb:121:in `<main>'
It would be nice if along with installation instructions, you could provide uninstall instructions
Can this be turned into a Oh My Zsh plugin ?
It would be great if, I was able to use the grunt icon for files named Gruntfile.js
(\ue74c).
I tried adding: Gruntfile.js grunt
to the file_aliases.yaml ad adding grunt "\ue74c"
to the files.yaml but it didn't work.
Suggested by @janga1997 - Rather than having colorls depend on Ruby, a Python script called colorls.py could be made from colorls.rb for making it easier for Pythonists.
My note - Creating a Python script should be easy. Requirements are on 3 libraries - one for colorizing string, one for reading from yaml files, and one for finding the width of current terminal screen. Once this is investigated, translation of colorls.rb to colorls.py line by line should be easy. 🎉
Because, attribution to open-source contributors is how we return back their ❤️
A lot of people have been mailing me, asking about how to get their prompt to look like the screenshots. Along with the configurations mentioned in the README, the powerlevel9k config I'm using can be found in this gist. This should also be put up in the README probably, next to the first screenshot. 😄
Reason: distributing executable as Ruby gem is notoriously hard to pull off.
Would it be ok if I tried cloning this idea (awesome one, btw) in Golang / Rust / Crystal / Haskell? Basically, any compiled language in which you can simply distribute binaries for different OSes.
Some folders like those of version control, deserve a special icon of their own rather than just a normal folder. For example, .git/
.
When lc
runs, there's a blank line before any output is printed. I know nothing about ruby - is it possible to remove this, or give an option of removing it (-q or similar)?
Really awesome work though! I'm a sucker for nice terminal enhancements.
I just installed colorls on mac, ruby 2.4.1 via rbenv, and seems to work ok, but it's not showing any .dot file
neither
colorls
colorls -r
colorls -f
return any of them, while ls -altr does
By converting the ruby script to a gem, the bin (shebang) file can directly be accessed by
gem install colorls
lc
This markdown file is intended to document the various mentions of this project. Here are some existing ones -
A shell file can be written that contains the basic function written:
ruby /path/to/colorls.rb $1
and straight away sourcing the bash shell itself.
This is just an alternative to the mentioned approach. I'm using fish shell, and as far as I know, writing a function is better compared to aliasing since functions are lazy-loaded, and hence faster than sourcing. So I'm not sure if this should be pursued.
Both aliases.yaml
and formats.yaml
have a certain order, in which data should be inserted. Both YAML files are key-value hashes, with -
aliases.yaml
: The values are sorted alphabetically. For each set of keys mapping to a value, those set of keys are also sorted alphabetically.formats.yaml
: The keys are sorted alphabetically.It'd be good to have a (Ruby?) script that automatically checks for this order, and use with Travis CI to decide when PRs are submitted.
Is there a way to do this? a good 3/4 of my home directory are dot files. Right now the output kind of pollutes my screen with a lot more files than I need to look at.
ls -l
works, but something like lc -l
doesn't. Having this feature to highlight file formats in strings would be a great feature.
Some files, like Procfile
are specific to heroku only, but cannot be identified due to lack of an extension.
Likewise, in certain cases, where the extension itself has dots, like .travis.yml
or webpack.tar.gz
, the behaviour in this is taken as per the last extension, and not as per the complete one. Could this be of any concern later?
Also, some of the folders, have a unique naming style, like gulpfile.js/
, here it is not possible to detect the kind of folder to be rendered (I think a symbol of gulp should be shown here, but that is perhaps nit-picking) since the name might not be specific.
Among the 3 cases pointed out above, the first case could be worked upon. I just wanted to point out the usecases that could be encountered.
This flag option is a standalone one, which can be used to print the various flags and use cases.
As discussed in DM, new icons can be added for undetected file systems/extensions by editing formats.yaml
and using the nerd-fonts README for reference.
Apart from that, if someone wishes to add more files, refer to the above README link. There is a file extension for each provided icon.
Currently, it's just a Ruby script that works, while following Rubocop styling standards. However, the code can definitely be made better and DRyier.
I'm trying to set up colorls on my linux-machine, and so far the application is working, but I lack the knowledge on how to get the icons to appear in my urxvt window.
Here's the font-line from my .Xresources:
URxvt*font: xft:DroidSansMonoForPowerline Nerd Font:pixelsize=15:antialias=true:hinting=true:autohint=true
This line works fine, it uses the proper typeface, but sadly the icons all appear as boxes.
Have I missed something, or is urxvt simply not capable of showing the icons?
On MacOS when trying to colorls / colorls -r
an empty directory, following errors get thrown:
/Users/-/.rvm/gems/ruby-2.3.0/gems/colorls-0.1.4/lib/colorls/core.rb:103:in `in_line': undefined method `+' for nil:NilClass (NoMethodError)
from /Users/-/.rvm/gems/ruby-2.3.0/gems/colorls-0.1.4/lib/colorls/core.rb:87:in `chunkify'
from /Users/-/.rvm/gems/ruby-2.3.0/gems/colorls-0.1.4/lib/colorls/core.rb:20:in `ls'
from /Users/-/.rvm/gems/ruby-2.3.0/gems/colorls-0.1.4/lib/colorls/flags.rb:19:in `process'
from /Users/-/.rvm/gems/ruby-2.3.0/gems/colorls-0.1.4/exe/colorls:4:in `<top (required)>'
from /Users/-/.rvm/gems/ruby-2.3.0/bin/colorls:23:in `load'
from /Users/-/.rvm/gems/ruby-2.3.0/bin/colorls:23:in `<main>'
from /Users/-/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
from /Users/-/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
Not really a no-go issue, but quite ugly.
It would be awesome if colorls would have a flag to print a tree output, similar to the tree command.
When I install colorls on my mac (with Ruby 2.4.1p111) and use it, it is working, but I get a bunch of warnings?
/usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/facets-3.1.0/lib/core/facets/filetest/separator_pattern.rb:4: warning: already initialized constant FileTest::SEPARATOR_PATTERN
/usr/local/opt/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/facets-3.1.0/lib/core/facets/filetest/separator_pattern.rb:4: warning: previous definition of SEPARATOR_PATTERN was here
/usr/local/opt/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/facets-3.1.0/lib/core/facets/kernel/ergo.rb:29: warning: already initialized constant NilClass::FUNCTOR
/usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/facets-3.1.0/lib/core/facets/kernel/ergo.rb:29: warning: previous definition of FUNCTOR was here
/usr/local/opt/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/facets-3.1.0/lib/core/facets/string/bracket.rb:3: warning: already initialized constant String::BRA2KET
/usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/facets-3.1.0/lib/core/facets/string/bracket.rb:3: warning: previous definition of BRA2KET was here
Is it possible to support the -l
option to behave like ls -l
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.