Color LS

forthebadge forthebadge

Gem Version Build Status PRs Welcome

A Ruby script that colorizes the ls output with color and icons. 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.

Example #1

If you're interested in knowing the powerlevel9k configuration to get this prompt, have a look at this gist.

Table of contents

Usage

(Back to top)

  • With -a : lc prints all directories, files and dotfiles in current directory.

Usage #1

  • With paths : lc path(s) -a prints all directories, files and dotfiles in given directory / directories.

Usage #2

  • With --report or -r flag : lc path(s) -r -a : Prints all directories, files and dotfiles in directories, along with a brief report about number of files and folders shown.

Usage #3 Usage #4

  • With --sort-dirs / -sd or --sort-files / -sf : Entries are sorted directories-first or files-first, and then alphabetically (case-insensitively) before being printed.

Usage #5 Usage #6

  • With --dirs / -d or --files / -f : Entries are filtered so that only directories or files are shown.

Usage #7 Usage #8

  • With -1 : Entries are printed in a column (one per line), just like ls -1 does.

Usage #9

  • Additional flags: --almost_all or -A, --long or -l, --tree or -t

Installation

(Back to top)

  1. Install Ruby (preferably, version > 2.1)
  2. Install the patched fonts of powerline nerd-font and/or font-awesome. Have a look at the Nerd Font README for more installation instructions.

    Note for iTerm2 users - Please enable the Nerd Font at iTerm2 > Preferences > Profiles > Text > Non-ASCII font > Knack Regular Nerd Font Complete.

  3. Install the colorls ruby gem with gem install colorls

    Note for rbenv users - In case of load error when using lc, please try the below patch.

    rbenv rehash
    rehash
    
  4. Enable tab completion for flags by entering following line to your shell configuration file (~/.bashrc or ~/.zshrc) :

    source $(dirname $(gem which colorls))/tab_complete.sh
    
  5. Start using colorls :tada:

  6. Have a look at Recommended configurations.

Recommended configurations

(Back to top)

  1. To add some short command (say, lc) with some flag options (say, -r)b y default, add this to your shell configuration file (~/.bashrc, ~/.zshrc or ~/.fishrc) : sh alias lc='colorls -r'
  2. For changing the icon(s) to other unicode icons of choice (select icons from here), change the YAML files in a text editor of your choice (say, subl)

    subl $(dirname $(gem which colorls))/yaml
    

Custom configurations

(Back to top)

You can overwrite the existing icons and colors mapping by creating yaml files in ~/.config/lscolors.

Each .yaml file inside the lib/colorls/yaml directory of this repo can be overwrited.

Let's say you want to add an icon for swift files, you might create a files.yaml inside ~/.config/lscolors and add the following:

swift: "\uF179"

Which will add the Apple logo to swift files.

Updating

(Back to top)

Want to update to the latest version of colorls?

gem update colorls

Uninstallation

(Back to top)

Want to uninstall and revert back to the old style? No issues (sob). Please feel free to open an issue regarding how we can enhance colorls.

gem uninstall colorls

Contributing

(Back to top)

Your contributions are always welcome! Please have a look at the contribution guidelines first. :tada:

License

(Back to top)

The MIT License (MIT) 2017 - Athitya Kumar. Please have a look at the LICENSE.md for more details.