2017-07-04 09:05:58 +02:00
# Color LS
2017-07-02 10:48:57 +02:00
2017-07-10 17:06:24 +02:00
[![forthebadge ](http://forthebadge.com/images/badges/made-with-ruby.svg )](http://forthebadge.com)
[![forthebadge ](http://forthebadge.com/images/badges/built-with-love.svg )](http://forthebadge.com)
2017-07-06 17:58:32 +02:00
[![Gem Version ](https://badge.fury.io/rb/colorls.svg )](https://badge.fury.io/rb/colorls)
2017-07-02 10:48:57 +02:00
[![Build Status ](https://travis-ci.org/athityakumar/colorls.svg?branch=master )](https://travis-ci.org/athityakumar/colorls)
2017-07-06 16:16:17 +02:00
[![PRs Welcome ](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=shields )](http://makeapullrequest.com)
2017-08-05 15:15:07 +02:00
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.
2017-06-29 19:02:18 +02:00
2017-10-29 23:52:14 +01:00
![image ](https://user-images.githubusercontent.com/17109060/32149040-04f3125c-bd25-11e7-8003-66fd29bc18d4.png )
2017-07-06 18:54:44 +02:00
2017-07-10 17:06:24 +02:00
*If you're interested in knowing the powerlevel9k configuration to get this prompt, have a look at [this gist ](https://gist.github.com/athityakumar/1bd5e9e24cd2a1891565573a893993eb ).*
2017-07-06 18:35:43 +02:00
# Table of contents
- [Usage ](#usage )
2017-10-29 23:52:14 +01:00
- [Flags ](#flags )
- `-1`
- `-a` (or) `--all`
- `-A` (or) `--almost-all`
- `-d` (or) `--dirs`
- `-f` (or) `--files`
- `-h` (or) `--help`
- `-l` (or) `--long`
- `-r` (or) `--report`
2019-01-11 07:36:02 +01:00
- `--tree` (or) `--tree=[DEPTH]`
2017-10-29 23:52:14 +01:00
- `--gs` (or) `--git-status`
- `--sd` (or) `--sort-dirs` or `--group-directories-first`
- `--sf` (or) `--sort-files`
2019-01-11 07:36:02 +01:00
- `-t`
2017-10-29 23:52:14 +01:00
- [Combination of flags ](#combination-of-flags )
2017-07-07 16:57:52 +02:00
- [Installation ](#installation )
2017-07-07 16:55:38 +02:00
- [Recommended configurations ](#recommended-configurations )
2017-10-05 04:51:10 +02:00
- [Custom configurations ](#custom-configurations )
2017-07-07 16:55:38 +02:00
- [Updating ](#updating )
2017-07-06 18:35:43 +02:00
- [Uninstallation ](#uninstallation )
2017-07-06 20:31:04 +02:00
- [Contributing ](#contributing )
- [License ](#license )
2017-07-06 18:35:43 +02:00
# Usage
2017-07-06 18:54:44 +02:00
[(Back to top) ](#table-of-contents )
2017-07-02 08:46:09 +02:00
2017-11-15 22:24:17 +01:00
Man pages have been added. Checkout `man colorls` .
2017-10-29 23:52:14 +01:00
### Flags
2017-10-30 00:22:30 +01:00
2017-10-29 23:52:14 +01:00
- With `-1` : Lists one entry per line
2017-07-02 08:46:09 +02:00
2017-10-29 23:52:14 +01:00
![image ](https://user-images.githubusercontent.com/17109060/32149062-4f0547ca-bd25-11e7-98b6-587467379704.png )
2017-07-02 08:46:09 +02:00
2017-10-29 23:52:14 +01:00
- With `-a` (or) `--all` : Does not ignore entries starting with '.'
2017-07-02 08:46:09 +02:00
2017-10-29 23:52:14 +01:00
![image ](https://user-images.githubusercontent.com/17109060/32149045-182eb39e-bd25-11e7-83d4-897cb14bcff3.png )
2017-07-02 08:46:09 +02:00
2017-10-29 23:52:14 +01:00
- With `-A` (or) `--almost-all` : Does not ignore entries starting with '.', except `./` and `../`
2017-07-02 08:46:09 +02:00
2017-10-29 23:52:14 +01:00
![image ](https://user-images.githubusercontent.com/17109060/32149046-1ef7664e-bd25-11e7-8bd9-bfc3c8b27b74.png )
2017-06-29 19:02:18 +02:00
2017-10-29 23:52:14 +01:00
- With `-d` (or) `--dirs` : Shows only directories
2017-07-05 07:36:05 +02:00
2017-10-29 23:52:14 +01:00
![image ](https://user-images.githubusercontent.com/17109060/32149066-5f842aa8-bd25-11e7-9bf0-23313b717182.png )
2017-07-05 09:36:40 +02:00
2017-10-29 23:52:14 +01:00
- With `-f` (or) `--files` : Shows only files
2017-07-05 09:36:40 +02:00
2017-10-29 23:52:14 +01:00
![image ](https://user-images.githubusercontent.com/17109060/32149065-5a27c9d4-bd25-11e7-9a2b-fd731d76a058.png )
2017-07-04 09:05:58 +02:00
2017-10-29 23:52:14 +01:00
- With `-h` (or) `--help` : Prints a very helpful help menu
2017-07-04 09:05:58 +02:00
2017-10-29 23:52:14 +01:00
![image ](https://user-images.githubusercontent.com/17109060/32149096-cf2cf5b0-bd25-11e7-84b6-909d79099c98.png )
2017-07-05 09:36:40 +02:00
2017-10-29 23:52:14 +01:00
- With `-l` (or) `--long` : Shows in long listing format
![image ](https://user-images.githubusercontent.com/17109060/32149049-2a63ae48-bd25-11e7-943c-5ceed25bd693.png )
- With `-r` (or) `--report` : Shows brief report about number of files and folders shown
![image ](https://user-images.githubusercontent.com/17109060/32149082-96a83fec-bd25-11e7-9081-7f77e4c90e90.png )
2019-01-11 07:36:02 +01:00
- With `--tree` (or) `--tree=[DEPTH]` : Shows tree view of the directory with the specified depth (default 3)
2017-10-29 23:52:14 +01:00
![image ](https://user-images.githubusercontent.com/17109060/32149051-32e596e4-bd25-11e7-93a9-5e50c8d2bb19.png )
- With `--gs` (or) `--git-status` : Shows git status for each entry
![image ](https://user-images.githubusercontent.com/17109060/32149075-7a1a1954-bd25-11e7-964e-1adb173aa2b9.png )
- With `--sd` (or) `--sort-dirs` or `--group-directories-first` : Shows directories first, followed by files
![image ](https://user-images.githubusercontent.com/17109060/32149068-65117fc0-bd25-11e7-8ada-0b055603e3fd.png )
- With `--sf` (or) `--sort-files` : Shows files first, followed by directories
![image ](https://user-images.githubusercontent.com/17109060/32149071-6b379de4-bd25-11e7-8764-a0c577e526a1.png )
2019-01-11 07:36:02 +01:00
- With `-t` : Sort by modification time, newest first (NEED TO ADD IMAGE)
2017-10-30 00:22:30 +01:00
- With color options : `--light` or `--dark` can be passed as a flag, to choose the appropriate color scheme. By default, the dark color scheme is chosen. In order to tweak any color, read [Custom configurations ](#custom-configurations ).
2017-10-29 23:52:14 +01:00
### Combination of flags
- Using `--gs` with `-t` :
![image ](https://user-images.githubusercontent.com/17109060/32149076-8423c864-bd25-11e7-816e-8642643d2c27.png )
- Using `--gs` with `-l` :
![image ](https://user-images.githubusercontent.com/17109060/32149078-899b0622-bd25-11e7-9810-d398eaa77e32.png )
- Using `--sd` with `-l` and `-A` :
![image ](https://user-images.githubusercontent.com/17109060/32149084-9eb2a416-bd25-11e7-8fb7-a9d336c6e038.png )
2017-08-05 15:15:07 +02:00
2017-07-06 18:35:43 +02:00
# Installation
2017-07-06 18:54:44 +02:00
[(Back to top) ](#table-of-contents )
2017-06-29 19:02:18 +02:00
2019-07-01 23:33:59 +02:00
1. Install Ruby (preferably, version > 2.3)
2017-07-21 01:25:20 +02:00
2. Install the patched fonts of powerline nerd-font and/or font-awesome. Have a look at the [Nerd Font README ](https://github.com/ryanoasis/nerd-fonts/blob/master/readme.md ) for more installation instructions.
2017-07-07 17:10:15 +02:00
2018-08-20 16:30:55 +02:00
*Note for `iTerm2` users - Please enable the Nerd Font at iTerm2 > Preferences > Profiles > Text > Non-ASCII font > Hack Regular Nerd Font Complete.*
2017-07-07 17:10:15 +02:00
2017-07-06 17:58:32 +02:00
3. Install the [colorls ](https://rubygems.org/gems/colorls/ ) ruby gem with `gem install colorls`
2017-07-06 20:50:28 +02:00
2017-07-07 13:46:51 +02:00
*Note for `rbenv` users - In case of load error when using `lc`, please try the below patch.*
2017-07-06 20:50:28 +02:00
2017-07-07 13:46:51 +02:00
```sh
rbenv rehash
rehash
```
2017-07-06 20:50:28 +02:00
2017-10-22 20:10:36 +02:00
4. Enable tab completion for flags by entering following line to your shell configuration file (`~/.bashrc` or `~/.zshrc` ) :
```bash
source $(dirname $(gem which colorls))/tab_complete.sh
```
5. Start using `colorls` :tada:
2017-07-06 17:58:32 +02:00
2017-10-30 00:22:30 +01:00
6. Have a look at [Recommended configurations ](#recommended-configurations ) and [Custom configurations ](#custom-configurations ).
2017-07-10 17:06:24 +02:00
2017-07-07 17:10:15 +02:00
# Recommended configurations
2017-07-06 18:35:43 +02:00
2017-07-06 18:54:44 +02:00
[(Back to top) ](#table-of-contents )
2017-07-06 17:58:32 +02:00
2017-10-30 00:22:30 +01:00
1. To add some short command (say, `lc` ) with some flag options (say, `-l` , `-A` , `--sd` ) by default, add this to your shell configuration file (`~/.bashrc`, `~/.zshrc` , etc.) :
2017-07-07 13:46:51 +02:00
```sh
2017-10-30 00:22:30 +01:00
alias lc='colorls -lA --sd'
2017-07-07 13:46:51 +02:00
```
2017-10-30 00:22:30 +01:00
2017-07-06 17:58:32 +02:00
2. For changing the icon(s) to other unicode icons of choice (select icons from [here ](https://nerdfonts.com/ )), change the YAML files in a text editor of your choice (say, `subl` )
2017-07-07 13:46:51 +02:00
```sh
2017-10-04 21:59:14 +02:00
subl $(dirname $(gem which colorls))/yaml
2017-07-07 13:46:51 +02:00
```
2017-07-01 12:11:41 +02:00
2017-10-05 04:44:56 +02:00
# Custom configurations
[(Back to top) ](#table-of-contents )
2017-10-30 00:22:30 +01:00
You can overwrite the existing icons and colors mapping by copying the yaml files from `$(dirname $(gem which colorls))/yaml` into `~/.config/colorls` , and changing them.
2017-10-05 04:44:56 +02:00
2017-10-30 00:22:30 +01:00
- To overwrite color mapping :
2017-10-05 04:44:56 +02:00
2017-10-30 00:22:30 +01:00
Please have a look at the [list of supported color names ](https://github.com/sickill/rainbow#color-list ). Let's say that you're using the dark color scheme and would like to change the color of untracked file (`??`) in the `--git-status` flag to yellow. Copy the defaut `dark_colors.yaml` and change it.
```sh
cp $(dirname $(gem which colorls))/yaml/dark_colors.yaml ~/.config/colorls/dark_colors.yaml`
```
In the `~/.config/colorls/dark_colors.yaml` file, change the color set for `untracked` from `darkorange` to `yellow` , and save the change.
```
untracked: yellow
```
- To overwrite icon mapping :
2018-01-12 17:09:39 +01:00
Please have a look at the [list of supported icons ](https://nerdfonts.com/ ). Let's say you want to add an icon for swift files. Copy the default `files.yaml` and change it.
2017-10-30 00:22:30 +01:00
```sh
cp $(dirname $(gem which colorls))/yaml/files.yaml ~/.config/colorls/files.yaml`
```
In the `~/.config/colorls/files.yaml` file, add a new icon / change an existing icon, and save the change.
2017-10-05 04:44:56 +02:00
2017-10-30 00:22:30 +01:00
```
swift: "\uF179"
```
2017-10-05 04:44:56 +02:00
2018-09-28 20:44:34 +02:00
- User contributed alias configurations :
- [@rjhilgefort ](https://gist.github.com/rjhilgefort/51ea47dd91bcd90cd6d9b3b199188c16 )
2017-07-07 16:55:38 +02:00
# Updating
[(Back to top) ](#table-of-contents )
Want to update to the latest version of `colorls` ?
```sh
gem update colorls
```
2017-07-06 20:50:28 +02:00
# Uninstallation
2017-07-06 18:35:43 +02:00
2017-07-06 18:54:44 +02:00
[(Back to top) ](#table-of-contents )
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` .
2017-07-04 12:39:45 +02:00
```sh
2017-07-06 17:58:32 +02:00
gem uninstall colorls
2017-07-04 12:39:45 +02:00
```
2017-07-06 20:20:51 +02:00
# Contributing
2017-07-06 20:31:04 +02:00
[(Back to top) ](#table-of-contents )
Your contributions are always welcome! Please have a look at the [contribution guidelines ](CONTRIBUTING.md ) first. :tada:
# License
[(Back to top) ](#table-of-contents )
The MIT License (MIT) 2017 - [Athitya Kumar ](https://github.com/athityakumar/ ). Please have a look at the [LICENSE.md ](LICENSE.md ) for more details.