colorls 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rubocop.yml +94 -0
- data/.travis.yml +24 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +88 -0
- data/Rakefile +6 -0
- data/colorls.gemspec +32 -0
- data/exe/lc +5 -0
- data/lib/colorls.rb +168 -0
- data/lib/colorls/flags.rb +63 -0
- data/lib/colorls/version.rb +3 -0
- data/lib/yaml/file_aliases.yaml +61 -0
- data/lib/yaml/files.yaml +55 -0
- data/lib/yaml/folder_aliases.yaml +2 -0
- data/lib/yaml/folders.yaml +7 -0
- data/readme/pending.png +0 -0
- data/readme/usage1.png +0 -0
- data/readme/usage2.png +0 -0
- data/readme/usage3.png +0 -0
- data/readme/usage4.png +0 -0
- data/readme/usage5.png +0 -0
- data/readme/usage6.png +0 -0
- data/readme/usage7.png +0 -0
- data/readme/usage8.png +0 -0
- data/readme/usage9.png +0 -0
- metadata +170 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8d5d529f0aa19641fbc905e343398ce7a8c4a8b8
|
4
|
+
data.tar.gz: 3cf666ab474decf7329366e5207b1a1a38a1cd39
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b6a71b8ea4eb5bc8d70d7ee146aae616b5bf524b7c252c5e17c893eb0aa8635e671d5941d7a02fafd696b99e5a4c796b3fa1f148863216c5498ecf9868b073b6
|
7
|
+
data.tar.gz: d84dc2ff0d5eeee166ab4495b903f1fcb617e6798a813be8f87f49c47f9ee7fc997510bbaffe793ce68ce0541520228477428034006261a9d32b0b58fd05ea4a
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
AllCops:
|
2
|
+
Include:
|
3
|
+
- 'lib/**/*'
|
4
|
+
Exclude:
|
5
|
+
- 'vendor/**/*'
|
6
|
+
- 'benchmarks/*'
|
7
|
+
- 'profile/*'
|
8
|
+
- 'lib/yaml/*'
|
9
|
+
DisplayCopNames: true
|
10
|
+
TargetRubyVersion: 2.1
|
11
|
+
|
12
|
+
# Preferred codebase style ---------------------------------------------
|
13
|
+
Layout/ExtraSpacing:
|
14
|
+
AllowForAlignment: true
|
15
|
+
|
16
|
+
Style/FormatString:
|
17
|
+
EnforcedStyle: percent
|
18
|
+
|
19
|
+
Style/AndOr:
|
20
|
+
EnforcedStyle: conditionals
|
21
|
+
|
22
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
23
|
+
EnforcedStyle: no_space
|
24
|
+
|
25
|
+
Layout/SpaceInsideBlockBraces:
|
26
|
+
EnforcedStyle: space
|
27
|
+
|
28
|
+
Layout/SpaceInsideHashLiteralBraces:
|
29
|
+
EnforcedStyle: no_space
|
30
|
+
|
31
|
+
Layout/AlignParameters:
|
32
|
+
EnforcedStyle: with_fixed_indentation
|
33
|
+
|
34
|
+
Style/EmptyElse:
|
35
|
+
EnforcedStyle: empty
|
36
|
+
|
37
|
+
Metrics/BlockLength:
|
38
|
+
Exclude:
|
39
|
+
- 'spec/**/*'
|
40
|
+
|
41
|
+
Metrics/LineLength:
|
42
|
+
Max: 120
|
43
|
+
|
44
|
+
Metrics/ModuleLength:
|
45
|
+
Max: 200
|
46
|
+
|
47
|
+
Metrics/ClassLength:
|
48
|
+
Max: 200
|
49
|
+
|
50
|
+
Metrics/ParameterLists:
|
51
|
+
Max: 10
|
52
|
+
|
53
|
+
Style/ParallelAssignment:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
Style/DoubleNegation:
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
Style/SingleLineBlockParams:
|
60
|
+
Enabled: false
|
61
|
+
|
62
|
+
Style/PerlBackrefs:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
Layout/SpaceAfterComma:
|
66
|
+
Enabled: false
|
67
|
+
|
68
|
+
Layout/SpaceAroundOperators:
|
69
|
+
Enabled: false
|
70
|
+
|
71
|
+
Style/EmptyCaseCondition:
|
72
|
+
Enabled: false
|
73
|
+
|
74
|
+
Style/FileName:
|
75
|
+
Enabled: false
|
76
|
+
|
77
|
+
Style/MultilineBlockChain:
|
78
|
+
Enabled: false
|
79
|
+
|
80
|
+
# Current preferred metrics --------------------------------------------
|
81
|
+
# Better values are encouraged, but not required.
|
82
|
+
Metrics/AbcSize:
|
83
|
+
Max: 20
|
84
|
+
|
85
|
+
Metrics/MethodLength:
|
86
|
+
Max: 15
|
87
|
+
|
88
|
+
Metrics/CyclomaticComplexity:
|
89
|
+
Max: 7
|
90
|
+
|
91
|
+
# TODO -----------------------------------------------------------------
|
92
|
+
|
93
|
+
Style/Documentation:
|
94
|
+
Enabled: false
|
data/.travis.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
language:
|
2
|
+
ruby
|
3
|
+
|
4
|
+
rvm:
|
5
|
+
- '2.1'
|
6
|
+
- '2.2'
|
7
|
+
- '2.3.0'
|
8
|
+
- '2.4.0'
|
9
|
+
|
10
|
+
script:
|
11
|
+
- bundle exec rubocop
|
12
|
+
- bundle exec rspec
|
13
|
+
- rake install
|
14
|
+
- lc
|
15
|
+
- lc -d
|
16
|
+
- lc -f
|
17
|
+
- lc -sd
|
18
|
+
- lc -sf
|
19
|
+
- lc -1
|
20
|
+
- lc -r
|
21
|
+
|
22
|
+
install:
|
23
|
+
- gem install bundler
|
24
|
+
- bundle install
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Athitya
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# Color LS
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/athityakumar/colorls.svg?branch=master)](https://travis-ci.org/athityakumar/colorls)
|
4
|
+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
|
5
|
+
|
6
|
+
A Ruby script that colorizes the `ls` output with color and icons. Here are the screenshots of working example on an iTerm2
|
7
|
+
terminal (Mac OS), `oh-my-zsh` with `powerlevel9k` theme and `powerline nerd-font + awesome-config` font.
|
8
|
+
|
9
|
+
![Example #1](readme/usage1.png)
|
10
|
+
|
11
|
+
# How to use
|
12
|
+
|
13
|
+
- Just `lc` : Prints all directories, files and dotfiles in current directory.
|
14
|
+
|
15
|
+
![Usage #1](readme/usage1.png)
|
16
|
+
|
17
|
+
- With paths : `lc path(s)` prints all directories, files and dotfiles in given directory / directories.
|
18
|
+
|
19
|
+
![Usage #2](readme/usage2.png)
|
20
|
+
|
21
|
+
- With `--report` or `-r` flag : `lc path(s) -r` : Prints all directories, files and dotfiles in directories, along with a brief report about number of files and folders shown.
|
22
|
+
|
23
|
+
![Usage #3](readme/usage3.png)
|
24
|
+
![Usage #4](readme/usage4.png)
|
25
|
+
|
26
|
+
- With `--sort-dirs` / `-sd` or `--sort-files` / `-sf` : Entries are sorted directories-first or files-first, and then alphabetically (case-insensitively) before being printed.
|
27
|
+
|
28
|
+
![Usage #5](readme/usage5.png)
|
29
|
+
![Usage #6](readme/usage6.png)
|
30
|
+
|
31
|
+
- With `--dirs` / `-d` or `--files` / `-f` : Entries are filtered so that only directories or files are shown.
|
32
|
+
|
33
|
+
![Usage #7](readme/usage7.png)
|
34
|
+
![Usage #8](readme/usage8.png)
|
35
|
+
|
36
|
+
- With `-1` : Entries are printed in a column (one per line), just like `ls -1` does.
|
37
|
+
|
38
|
+
![Usage #9](readme/usage9.png)
|
39
|
+
|
40
|
+
# Installation steps
|
41
|
+
|
42
|
+
1. Install Ruby (prefably, version > 2.1)
|
43
|
+
2. Install the patched fonts of powerline nerd-font and/or font-awesome.
|
44
|
+
3. Clone this repository to `~/bin` (create if not exist or clone elsewhere) with
|
45
|
+
```sh
|
46
|
+
cd ~/bin && git clone https://github.com/athityakumar/colorls.git
|
47
|
+
```
|
48
|
+
4. Navigate to this cloned directory : `cd colorls`
|
49
|
+
5. Install bundler and dependencies :
|
50
|
+
```
|
51
|
+
gem install bundler
|
52
|
+
bundle install
|
53
|
+
```
|
54
|
+
6. For CLI functionality, add a function (say, `lc`) to your shell configuration file (`~/.bashrc` or `~/.zshrc`) :
|
55
|
+
```sh
|
56
|
+
lc () { ruby ~/bin/colorls/colorls.rb $1; }
|
57
|
+
```
|
58
|
+
7. If you like the report flag you can make it default by adding:
|
59
|
+
```sh
|
60
|
+
alias lc='lc -r'
|
61
|
+
```
|
62
|
+
8. Change the YAML files, if required. (Say, to add / change / remove some icons)
|
63
|
+
9. Open a new terminal, and start using `lc` :tada:
|
64
|
+
|
65
|
+
_NOTE: If you're iTerm2 on Mac, you may have to enable the nerd-font at iTerm2 > Preferences > Profiles > Text > Non-Ascii font > Knack Regular Nerd Font Complete_
|
66
|
+
|
67
|
+
# Uninstall Instructions
|
68
|
+
|
69
|
+
Want to uninstall and revert back to the old style?
|
70
|
+
```sh
|
71
|
+
rm -rf ~/bin/colorls
|
72
|
+
```
|
73
|
+
Run the above command and reset your terminal profile.
|
74
|
+
|
75
|
+
# Tweaking this project
|
76
|
+
|
77
|
+
![Pending formats](readme/pending.png)
|
78
|
+
|
79
|
+
There are a couple of formats that aren't recognized yet. Custom file formats and icons can be added by changing the YAML files in this repository. Also, feel free to send a Pull Request here with the added icons. :smile:
|
80
|
+
|
81
|
+
Please feel free to contribute to this project, by
|
82
|
+
- opening an issue for reporting any bug / suggesting any enhancement
|
83
|
+
- cleaning up the `colorls.rb` ruby script with more functionalities.
|
84
|
+
- adding support for more icons by editing the YAML files.
|
85
|
+
|
86
|
+
# LICENSE
|
87
|
+
|
88
|
+
MIT License 2017 - [Athitya Kumar](https://github.com/athityakumar/).
|
data/Rakefile
ADDED
data/colorls.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'colorls/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'colorls'
|
9
|
+
spec.version = ColorLS::VERSION
|
10
|
+
spec.authors = ['Athitya']
|
11
|
+
spec.email = ['athityakumar@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = "A Ruby CLI gem that beautifies the terminal's ls command, with color and font-awesome icons."
|
14
|
+
spec.homepage = 'https://github.com/athityakumar/colorls'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = 'lc'
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_runtime_dependency 'colorize'
|
25
|
+
spec.add_runtime_dependency 'facets'
|
26
|
+
spec.add_runtime_dependency 'ruby-terminfo'
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
29
|
+
spec.add_development_dependency 'rake'
|
30
|
+
spec.add_development_dependency 'rspec'
|
31
|
+
spec.add_development_dependency 'rubocop'
|
32
|
+
end
|
data/exe/lc
ADDED
data/lib/colorls.rb
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require 'yaml'
|
3
|
+
require 'facets'
|
4
|
+
require 'terminfo'
|
5
|
+
|
6
|
+
require 'colorls/flags'
|
7
|
+
# Source for icons unicode: http://nerdfonts.com/
|
8
|
+
module ColorLS
|
9
|
+
class Core
|
10
|
+
def initialize(input=nil, report: false, sort: false, show: false, one_per_line: false)
|
11
|
+
@input = input || Dir.pwd
|
12
|
+
@count = {folders: 0, recognized_files: 0, unrecognized_files: 0}
|
13
|
+
@report = report
|
14
|
+
@sort = sort
|
15
|
+
@show = show
|
16
|
+
@one_per_line = one_per_line
|
17
|
+
@screen_width = ::TermInfo.screen_size.last
|
18
|
+
|
19
|
+
init_contents
|
20
|
+
@max_widths = @contents.map(&:length)
|
21
|
+
init_icons
|
22
|
+
end
|
23
|
+
|
24
|
+
def ls
|
25
|
+
@contents = chunkify
|
26
|
+
@max_widths = @contents.transpose.map { |c| c.map(&:length).max }
|
27
|
+
@contents.each { |chunk| ls_line(chunk) }
|
28
|
+
print "\n"
|
29
|
+
display_report if @report
|
30
|
+
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def init_contents
|
37
|
+
@contents = Dir.entries(@input) - %w[. ..]
|
38
|
+
|
39
|
+
filter_contents if @show
|
40
|
+
sort_contents if @sort
|
41
|
+
|
42
|
+
@total_content_length = @contents.length
|
43
|
+
end
|
44
|
+
|
45
|
+
def filter_contents
|
46
|
+
@contents.keep_if do |x|
|
47
|
+
next Dir.exist?("#{@input}/#{x}") if @show == :dirs
|
48
|
+
!Dir.exist?("#{@input}/#{x}")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def sort_contents
|
53
|
+
@contents.sort! { |a, b| cmp_by_dirs(a, b) }
|
54
|
+
end
|
55
|
+
|
56
|
+
def cmp_by_dirs(a, b)
|
57
|
+
is_a_dir = Dir.exist?("#{@input}/#{a}")
|
58
|
+
is_b_dir = Dir.exist?("#{@input}/#{b}")
|
59
|
+
|
60
|
+
return cmp_by_alpha(a, b) unless is_a_dir ^ is_b_dir
|
61
|
+
|
62
|
+
result = is_a_dir ? -1 : 1
|
63
|
+
result *= -1 if @sort == :files
|
64
|
+
result
|
65
|
+
end
|
66
|
+
|
67
|
+
def cmp_by_alpha(a, b)
|
68
|
+
a.downcase <=> b.downcase
|
69
|
+
end
|
70
|
+
|
71
|
+
def init_icons
|
72
|
+
@files = load_from_yaml('files.yaml')
|
73
|
+
@file_aliases = load_from_yaml('file_aliases.yaml', true)
|
74
|
+
@folders = load_from_yaml('folders.yaml')
|
75
|
+
@folder_aliases = load_from_yaml('folder_aliases.yaml', true)
|
76
|
+
|
77
|
+
@file_keys = @files.keys
|
78
|
+
@file_aliase_keys = @file_aliases.keys
|
79
|
+
@folder_keys = @folders.keys
|
80
|
+
@folder_aliase_keys = @folder_aliases.keys
|
81
|
+
|
82
|
+
@all_files = @file_keys + @file_aliase_keys
|
83
|
+
@all_folders = @folder_keys + @folder_aliase_keys
|
84
|
+
end
|
85
|
+
|
86
|
+
def chunkify
|
87
|
+
return @contents.zip if @one_per_line
|
88
|
+
|
89
|
+
chunk_size = @contents.count
|
90
|
+
|
91
|
+
until in_line(chunk_size) || chunk_size <= 1
|
92
|
+
chunk_size -= 1
|
93
|
+
chunk = get_chunk(chunk_size)
|
94
|
+
end
|
95
|
+
|
96
|
+
chunk || [@contents]
|
97
|
+
end
|
98
|
+
|
99
|
+
def get_chunk(chunk_size)
|
100
|
+
chunk = @contents.each_slice(chunk_size).to_a
|
101
|
+
chunk.last += [''] * (chunk_size - chunk.last.count)
|
102
|
+
@max_widths = chunk.transpose.map { |c| c.map(&:length).max }
|
103
|
+
chunk
|
104
|
+
end
|
105
|
+
|
106
|
+
def in_line(chunk_size)
|
107
|
+
return false if @max_widths.sum + 6 * chunk_size > @screen_width
|
108
|
+
true
|
109
|
+
end
|
110
|
+
|
111
|
+
def display_report
|
112
|
+
print "\n Found #{@total_content_length} contents in directory "
|
113
|
+
.colorize(:white)
|
114
|
+
|
115
|
+
print File.expand_path(@input).to_s.colorize(:blue)
|
116
|
+
|
117
|
+
puts "\n\n\tFolders\t\t\t: #{@count[:folders]}"\
|
118
|
+
"\n\tRecognized files\t: #{@count[:recognized_files]}"\
|
119
|
+
"\n\tUnrecognized files\t: #{@count[:unrecognized_files]}"
|
120
|
+
.colorize(:white)
|
121
|
+
end
|
122
|
+
|
123
|
+
def fetch_string(content, key, color, increment)
|
124
|
+
@count[increment] += 1
|
125
|
+
value = increment == :folders ? @folders[key] : @files[key]
|
126
|
+
logo = value.gsub(/\\u[\da-f]{4}/i) { |m| [m[-4..-1].to_i(16)].pack('U') }
|
127
|
+
|
128
|
+
"#{logo} #{content}".colorize(color)
|
129
|
+
end
|
130
|
+
|
131
|
+
def load_from_yaml(filename, aliase=false)
|
132
|
+
filepath = File.join(File.dirname(__FILE__),"yaml/#{filename}")
|
133
|
+
yaml = YAML.safe_load(File.read(filepath)).symbolize_keys
|
134
|
+
return yaml unless aliase
|
135
|
+
yaml
|
136
|
+
.to_a
|
137
|
+
.map! { |k, v| [k, v.to_sym] }
|
138
|
+
.to_h
|
139
|
+
end
|
140
|
+
|
141
|
+
def ls_line(chunk)
|
142
|
+
print "\n"
|
143
|
+
chunk.each_with_index do |content, i|
|
144
|
+
break if content.empty?
|
145
|
+
|
146
|
+
print " #{fetch_string(content, *options(content))}"
|
147
|
+
print Dir.exist?("#{@input}/#{content}") ? '/'.colorize(:blue) : ' '
|
148
|
+
print ' ' * (@max_widths[i] - content.length)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def options(content)
|
153
|
+
if Dir.exist?("#{@input}/#{content}")
|
154
|
+
key = content.to_sym
|
155
|
+
return %i[folder blue folders] unless @all_folders.include?(key)
|
156
|
+
key = @folder_aliases[key] unless @folder_keys.include?(key)
|
157
|
+
return [key, :blue, :folders]
|
158
|
+
end
|
159
|
+
|
160
|
+
key = content.split('.').last.downcase.to_sym
|
161
|
+
|
162
|
+
return %i[file yellow unrecognized_files] unless @all_files.include?(key)
|
163
|
+
|
164
|
+
key = @file_aliases[key] unless @file_keys.include?(key)
|
165
|
+
[key, :green, :recognized_files]
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module ColorLS
|
2
|
+
class Flags
|
3
|
+
def initialize(*args)
|
4
|
+
@args = args
|
5
|
+
@opts = {
|
6
|
+
show: fetch_show_opts,
|
7
|
+
sort: fetch_sort_opts,
|
8
|
+
report: flag_given?(%w[-r --report]),
|
9
|
+
one_per_line: flag_given?(%w[-1])
|
10
|
+
}
|
11
|
+
|
12
|
+
return if @opts[:show].nil? || @opts[:sort].nil?
|
13
|
+
|
14
|
+
@args.keep_if { |arg| !arg.start_with?('-') }
|
15
|
+
end
|
16
|
+
|
17
|
+
def process
|
18
|
+
return Core.new(@opts).ls if @args.empty?
|
19
|
+
|
20
|
+
@args.each do |path|
|
21
|
+
next STDERR.puts "\n Specified directory '#{path}' doesn't exist.".colorize(:red) unless Dir.exist?(path)
|
22
|
+
Core.new(path, @opts).ls
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def flag_given?(flags)
|
29
|
+
flags.each { |flag| return true if @args.include?(flag) }
|
30
|
+
false
|
31
|
+
end
|
32
|
+
|
33
|
+
def fetch_show_opts
|
34
|
+
show_dirs_only = flag_given? %w[-d --dirs]
|
35
|
+
show_files_only = flag_given? %w[-f --files]
|
36
|
+
|
37
|
+
if show_files_only && show_dirs_only
|
38
|
+
STDERR.puts "\n Restrain from using -d and -f flags together."
|
39
|
+
.colorize(:red)
|
40
|
+
return nil
|
41
|
+
else
|
42
|
+
return :files if show_files_only
|
43
|
+
return :dirs if show_dirs_only
|
44
|
+
false
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def fetch_sort_opts
|
49
|
+
sort_dirs_first = flag_given? %w[-sd --sort-dirs]
|
50
|
+
sort_files_first = flag_given? %w[-sf --sort-files]
|
51
|
+
|
52
|
+
if sort_dirs_first && sort_files_first
|
53
|
+
STDERR.puts "\n Restrain from using -sd and -sf flags together."
|
54
|
+
.colorize(:red)
|
55
|
+
return nil
|
56
|
+
else
|
57
|
+
return :files if sort_files_first
|
58
|
+
return :dirs if sort_dirs_first
|
59
|
+
false
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
apk: android
|
2
|
+
ds_store: apple
|
3
|
+
localized: apple
|
4
|
+
mp3: audio
|
5
|
+
scss: css
|
6
|
+
docx: doc
|
7
|
+
gdoc: doc
|
8
|
+
mobi: ebook
|
9
|
+
eot: font
|
10
|
+
otf: font
|
11
|
+
ttf: font
|
12
|
+
woff: font
|
13
|
+
editorconfig: git
|
14
|
+
gitconfig: git
|
15
|
+
gitignore: git
|
16
|
+
gitignore_global: git
|
17
|
+
lhs: hs
|
18
|
+
bmp: image
|
19
|
+
gif: image
|
20
|
+
jpeg: image
|
21
|
+
jpg: image
|
22
|
+
png: image
|
23
|
+
svg: image
|
24
|
+
markdown: md
|
25
|
+
mkd: md
|
26
|
+
rdoc: md
|
27
|
+
readme: md
|
28
|
+
license: md
|
29
|
+
pptx: ppt
|
30
|
+
gslides: ppt
|
31
|
+
pyc: py
|
32
|
+
rdata: r
|
33
|
+
rds: r
|
34
|
+
gemfile: rb
|
35
|
+
gemspec: rb
|
36
|
+
guardfile: rb
|
37
|
+
lock: rb
|
38
|
+
procfile: rb
|
39
|
+
rakefile: rb
|
40
|
+
rspec: rb
|
41
|
+
rspec_status: rb
|
42
|
+
rspec_parallel: rb
|
43
|
+
ru: rb
|
44
|
+
bash: shell
|
45
|
+
bashrc: shell
|
46
|
+
bash_history: shell
|
47
|
+
bash_profile: shell
|
48
|
+
sh: shell
|
49
|
+
zsh: shell
|
50
|
+
zsh-theme: shell
|
51
|
+
zshrc: shell
|
52
|
+
mp4: video
|
53
|
+
exe: windows
|
54
|
+
ini: windows
|
55
|
+
csv: xls
|
56
|
+
gsheet: xls
|
57
|
+
xlsx: xls
|
58
|
+
xul: xml
|
59
|
+
yaml: yml
|
60
|
+
rar: zip
|
61
|
+
tar: zip
|
data/lib/yaml/files.yaml
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
ai: "\ue7b4"
|
2
|
+
android: "\uf17b"
|
3
|
+
apple: "\uf179"
|
4
|
+
audio: "\uf001"
|
5
|
+
avro: "\ue60b"
|
6
|
+
c: "\ue61e"
|
7
|
+
clj: "\ue768"
|
8
|
+
coffee: "\uf0f4"
|
9
|
+
conf: "\ue615"
|
10
|
+
cpp: "\ue61d"
|
11
|
+
css: "\ue749"
|
12
|
+
d: "\ue7af"
|
13
|
+
dart: "\ue798"
|
14
|
+
db: "\uf1c0"
|
15
|
+
diff: "\uf440"
|
16
|
+
doc: "\uf1c2"
|
17
|
+
ebook: "\ue28b"
|
18
|
+
erl: "\ue7b1"
|
19
|
+
file: "\uf15b"
|
20
|
+
font: "\uf031"
|
21
|
+
gform: "\uf298"
|
22
|
+
git: "\uf1d3"
|
23
|
+
go: "\ue724"
|
24
|
+
hs: "\ue777"
|
25
|
+
html: "\uf13b"
|
26
|
+
image: "\uf1c5"
|
27
|
+
java: "\ue204"
|
28
|
+
js: "\ue74e"
|
29
|
+
json: "\ue60b"
|
30
|
+
less: "\ue758"
|
31
|
+
lua: "\ue620"
|
32
|
+
md: "\uf48a"
|
33
|
+
mustache: "\ue60f"
|
34
|
+
pdf: "\uf1c1"
|
35
|
+
php: "\ue73d"
|
36
|
+
pl: "\ue769"
|
37
|
+
ppt: "\uf1c4"
|
38
|
+
psd: "\ue7b8"
|
39
|
+
py: "\ue606"
|
40
|
+
r: "\uf25d"
|
41
|
+
rb: "\ue21e"
|
42
|
+
rdb: "\ue76d"
|
43
|
+
rss: "\uf09e"
|
44
|
+
scala: "\ue737"
|
45
|
+
shell: "\uf489"
|
46
|
+
styl: "\ue600"
|
47
|
+
twig: "\ue61c"
|
48
|
+
txt: "\uf15c"
|
49
|
+
video: "\uf03d"
|
50
|
+
vim: "\ue62b"
|
51
|
+
windows: "\uf17a"
|
52
|
+
xls: "\uf1c3"
|
53
|
+
xml: "\ue619"
|
54
|
+
yml: "\uf481"
|
55
|
+
zip: "\uf410"
|
data/readme/pending.png
ADDED
Binary file
|
data/readme/usage1.png
ADDED
Binary file
|
data/readme/usage2.png
ADDED
Binary file
|
data/readme/usage3.png
ADDED
Binary file
|
data/readme/usage4.png
ADDED
Binary file
|
data/readme/usage5.png
ADDED
Binary file
|
data/readme/usage6.png
ADDED
Binary file
|
data/readme/usage7.png
ADDED
Binary file
|
data/readme/usage8.png
ADDED
Binary file
|
data/readme/usage9.png
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: colorls
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Athitya
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: facets
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby-terminfo
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.15'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.15'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- athityakumar@gmail.com
|
114
|
+
executables:
|
115
|
+
- lc
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rubocop.yml"
|
121
|
+
- ".travis.yml"
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- colorls.gemspec
|
127
|
+
- exe/lc
|
128
|
+
- lib/colorls.rb
|
129
|
+
- lib/colorls/flags.rb
|
130
|
+
- lib/colorls/version.rb
|
131
|
+
- lib/yaml/file_aliases.yaml
|
132
|
+
- lib/yaml/files.yaml
|
133
|
+
- lib/yaml/folder_aliases.yaml
|
134
|
+
- lib/yaml/folders.yaml
|
135
|
+
- readme/pending.png
|
136
|
+
- readme/usage1.png
|
137
|
+
- readme/usage2.png
|
138
|
+
- readme/usage3.png
|
139
|
+
- readme/usage4.png
|
140
|
+
- readme/usage5.png
|
141
|
+
- readme/usage6.png
|
142
|
+
- readme/usage7.png
|
143
|
+
- readme/usage8.png
|
144
|
+
- readme/usage9.png
|
145
|
+
homepage: https://github.com/athityakumar/colorls
|
146
|
+
licenses:
|
147
|
+
- MIT
|
148
|
+
metadata: {}
|
149
|
+
post_install_message:
|
150
|
+
rdoc_options: []
|
151
|
+
require_paths:
|
152
|
+
- lib
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
requirements: []
|
164
|
+
rubyforge_project:
|
165
|
+
rubygems_version: 2.6.12
|
166
|
+
signing_key:
|
167
|
+
specification_version: 4
|
168
|
+
summary: A Ruby CLI gem that beautifies the terminal's ls command, with color and
|
169
|
+
font-awesome icons.
|
170
|
+
test_files: []
|