colorls 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +44 -0
- data/{LICENSE.txt → LICENSE.md} +2 -2
- data/README.md +60 -42
- data/colorls.gemspec +2 -2
- data/exe/{lc → colorls} +0 -0
- data/lib/colorls.rb +1 -162
- data/lib/colorls/core.rb +161 -0
- data/lib/colorls/version.rb +1 -1
- data/lib/yaml/file_aliases.yaml +9 -1
- data/lib/yaml/files.yaml +8 -3
- data/lib/yaml/folders.yaml +2 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65bb6af39e0cef4207180fd355951ed8af588467
|
4
|
+
data.tar.gz: 9ddd72d0fee92a585bd70c5a3127d6e7e9400be1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d6bc7bb007ce73ac38758bcccd772047d1322a749fbe1b994b9899ec6cb4c0e7d2a915731e93c0023593fe980580f6d144a679954084a81a3b33b4e6c6ef225
|
7
|
+
data.tar.gz: 532d8723491a7b1053e5cb659f85d9b1da8c898779aff2c25ea307b1010178e9fc7dd96893f1c9aa235d1715b580089dbdac1ac9536aab37b554a59b0c131f41
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Contribution guidelines
|
2
|
+
|
3
|
+
First of all, thanks for thinking of contributing to this project. :smile:
|
4
|
+
|
5
|
+
Before sending a Pull Request, please make sure that you're assigned the task on a GitHub issue.
|
6
|
+
|
7
|
+
- If a relevant issue already exists, discuss on the issue and get it assigned to yourself on GitHub.
|
8
|
+
- If no relevant issue exists, open a new issue and get it assigned to yourself on GitHub.
|
9
|
+
|
10
|
+
Please proceed with a Pull Request only after you're assigned. It'd be sad if your Pull Request (and your hardwork) isn't accepted just because it isn't idealogically compatible.
|
11
|
+
|
12
|
+
# Developing the gem
|
13
|
+
|
14
|
+
1. Install with
|
15
|
+
|
16
|
+
```sh
|
17
|
+
git clone https://github.com/athityakumar/colorls
|
18
|
+
cd colorls
|
19
|
+
gem install bundler
|
20
|
+
bundle install
|
21
|
+
```
|
22
|
+
|
23
|
+
2. Make your changes in a different git branch (say, `add-new-flag`). These changes can be
|
24
|
+
|
25
|
+
- adding better icons to [YAML files](lib/yaml/)
|
26
|
+
- adding more flag options to the ruby gem.
|
27
|
+
|
28
|
+
3. (Optional) To test whether `lc` is working properly, do
|
29
|
+
```sh
|
30
|
+
rake install
|
31
|
+
lc # start using lc
|
32
|
+
```
|
33
|
+
|
34
|
+
4. (Required for YAML file changes) These are the specifications for the YAML files -
|
35
|
+
|
36
|
+
- `files.yaml`, `folders.yaml` : The keys are sorted alphabetically.
|
37
|
+
- `file_aliases.yaml`, `folder_aliases.yaml` : The values are sorted alphabetically. For each set of keys mapping to a value, those set of keys are also sorted alphabetically.
|
38
|
+
|
39
|
+
5. Check before pushing
|
40
|
+
|
41
|
+
```sh
|
42
|
+
bundle exec rubocop
|
43
|
+
bundle exec rspec
|
44
|
+
```
|
data/{LICENSE.txt → LICENSE.md}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2017 Athitya
|
3
|
+
Copyright (c) 2017 [Athitya Kumar](https://github.com/athityakumar/)
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,14 +1,26 @@
|
|
1
1
|
# Color LS
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/colorls)
|
3
4
|
[](https://travis-ci.org/athityakumar/colorls)
|
4
|
-
[](http://makeapullrequest.com)
|
6
|
+
[](https://github.com/sindresorhus/awesome)
|
5
7
|
|
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
|
+
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.
|
8
9
|
|
9
10
|

|
10
11
|
|
11
|
-
#
|
12
|
+
# Table of contents
|
13
|
+
|
14
|
+
- [Usage](#usage)
|
15
|
+
- [Installatation](#installation)
|
16
|
+
- [Optional configurations](#optional-configurations)
|
17
|
+
- [Uninstallation](#uninstallation)
|
18
|
+
- [Contributing](#contributing)
|
19
|
+
- [License](#license)
|
20
|
+
|
21
|
+
# Usage
|
22
|
+
|
23
|
+
[(Back to top)](#table-of-contents)
|
12
24
|
|
13
25
|
- Just `lc` : Prints all directories, files and dotfiles in current directory.
|
14
26
|
|
@@ -37,52 +49,58 @@ terminal (Mac OS), `oh-my-zsh` with `powerlevel9k` theme and `powerline nerd-fon
|
|
37
49
|
|
38
50
|

|
39
51
|
|
40
|
-
# Installation
|
52
|
+
# Installation
|
53
|
+
|
54
|
+
[(Back to top)](#table-of-contents)
|
41
55
|
|
42
56
|
1. Install Ruby (prefably, version > 2.1)
|
43
57
|
2. Install the patched fonts of powerline nerd-font and/or font-awesome.
|
44
|
-
3.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
58
|
+
3. Install the [colorls](https://rubygems.org/gems/colorls/) ruby gem with `gem install colorls`
|
59
|
+
|
60
|
+
*Note for `rbenv` users - In case of load error when using `lc`, please try the below patch.*
|
61
|
+
|
62
|
+
```sh
|
63
|
+
rbenv rehash
|
64
|
+
rehash
|
65
|
+
```
|
66
|
+
|
67
|
+
4. Start using `lc` :tada:
|
68
|
+
|
69
|
+
# Optional configurations
|
70
|
+
|
71
|
+
[(Back to top)](#table-of-contents)
|
72
|
+
|
73
|
+
1. To add some flag options by default, add this to your shell configuration file (`~/.bashrc`, `~/.zshrc` or `~/.fishrc`) :
|
74
|
+
```sh
|
75
|
+
alias lc='lc -r'
|
76
|
+
```
|
77
|
+
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`)
|
78
|
+
|
79
|
+
```sh
|
80
|
+
subl $(gem which colorls)/../yaml/
|
81
|
+
```
|
82
|
+
|
83
|
+
_NOTE: If you're using iTerm2 on Mac, you may have to enable the nerd-font at iTerm2 > Preferences > Profiles > Text > Non-Ascii font > Knack Regular Nerd Font Complete_
|
84
|
+
|
85
|
+
# Uninstallation
|
86
|
+
|
87
|
+
[(Back to top)](#table-of-contents)
|
88
|
+
|
89
|
+
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`.
|
90
|
+
|
70
91
|
```sh
|
71
|
-
|
92
|
+
gem uninstall colorls
|
72
93
|
```
|
73
|
-
Run the above command and reset your terminal profile.
|
74
94
|
|
75
|
-
#
|
95
|
+
# Contributing
|
96
|
+
|
97
|
+
[(Back to top)](#table-of-contents)
|
76
98
|
|
77
|
-
 first. :tada:
|
78
100
|
|
79
|
-
|
101
|
+
# License
|
80
102
|
|
81
|
-
|
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.
|
103
|
+
[(Back to top)](#table-of-contents)
|
85
104
|
|
86
|
-
# LICENSE
|
87
105
|
|
88
|
-
MIT License 2017 - [Athitya Kumar](https://github.com/athityakumar/).
|
106
|
+
The MIT License (MIT) 2017 - [Athitya Kumar](https://github.com/athityakumar/). Please have a look at the [LICENSE.md](LICENSE.md) for more details.
|
data/colorls.gemspec
CHANGED
@@ -7,7 +7,7 @@ require 'colorls/version'
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = 'colorls'
|
9
9
|
spec.version = ColorLS::VERSION
|
10
|
-
spec.authors = ['Athitya']
|
10
|
+
spec.authors = ['Athitya Kumar']
|
11
11
|
spec.email = ['athityakumar@gmail.com']
|
12
12
|
|
13
13
|
spec.summary = "A Ruby CLI gem that beautifies the terminal's ls command, with color and font-awesome icons."
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
f.match(%r{^(test|spec|features)/})
|
19
19
|
end
|
20
20
|
spec.bindir = 'exe'
|
21
|
-
spec.executables = '
|
21
|
+
spec.executables = 'colorls'
|
22
22
|
spec.require_paths = ['lib']
|
23
23
|
|
24
24
|
spec.add_runtime_dependency 'colorize'
|
data/exe/{lc → colorls}
RENAMED
File without changes
|
data/lib/colorls.rb
CHANGED
@@ -3,166 +3,5 @@ require 'yaml'
|
|
3
3
|
require 'facets'
|
4
4
|
require 'terminfo'
|
5
5
|
|
6
|
+
require 'colorls/core'
|
6
7
|
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
|
data/lib/colorls/core.rb
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
module ColorLS
|
2
|
+
class Core
|
3
|
+
def initialize(input=nil, report: false, sort: false, show: false, one_per_line: false)
|
4
|
+
@input = input || Dir.pwd
|
5
|
+
@count = {folders: 0, recognized_files: 0, unrecognized_files: 0}
|
6
|
+
@report = report
|
7
|
+
@sort = sort
|
8
|
+
@show = show
|
9
|
+
@one_per_line = one_per_line
|
10
|
+
@screen_width = ::TermInfo.screen_size.last
|
11
|
+
|
12
|
+
init_contents
|
13
|
+
@max_widths = @contents.map(&:length)
|
14
|
+
init_icons
|
15
|
+
end
|
16
|
+
|
17
|
+
def ls
|
18
|
+
@contents = chunkify
|
19
|
+
@max_widths = @contents.transpose.map { |c| c.map(&:length).max }
|
20
|
+
@contents.each { |chunk| ls_line(chunk) }
|
21
|
+
print "\n"
|
22
|
+
display_report if @report
|
23
|
+
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def init_contents
|
30
|
+
@contents = Dir.entries(@input) - %w[. ..]
|
31
|
+
|
32
|
+
filter_contents if @show
|
33
|
+
sort_contents if @sort
|
34
|
+
|
35
|
+
@total_content_length = @contents.length
|
36
|
+
end
|
37
|
+
|
38
|
+
def filter_contents
|
39
|
+
@contents.keep_if do |x|
|
40
|
+
next Dir.exist?("#{@input}/#{x}") if @show == :dirs
|
41
|
+
!Dir.exist?("#{@input}/#{x}")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def sort_contents
|
46
|
+
@contents.sort! { |a, b| cmp_by_dirs(a, b) }
|
47
|
+
end
|
48
|
+
|
49
|
+
def cmp_by_dirs(a, b)
|
50
|
+
is_a_dir = Dir.exist?("#{@input}/#{a}")
|
51
|
+
is_b_dir = Dir.exist?("#{@input}/#{b}")
|
52
|
+
|
53
|
+
return cmp_by_alpha(a, b) unless is_a_dir ^ is_b_dir
|
54
|
+
|
55
|
+
result = is_a_dir ? -1 : 1
|
56
|
+
result *= -1 if @sort == :files
|
57
|
+
result
|
58
|
+
end
|
59
|
+
|
60
|
+
def cmp_by_alpha(a, b)
|
61
|
+
a.downcase <=> b.downcase
|
62
|
+
end
|
63
|
+
|
64
|
+
def init_icons
|
65
|
+
@files = load_from_yaml('files.yaml')
|
66
|
+
@file_aliases = load_from_yaml('file_aliases.yaml', true)
|
67
|
+
@folders = load_from_yaml('folders.yaml')
|
68
|
+
@folder_aliases = load_from_yaml('folder_aliases.yaml', true)
|
69
|
+
|
70
|
+
@file_keys = @files.keys
|
71
|
+
@file_aliase_keys = @file_aliases.keys
|
72
|
+
@folder_keys = @folders.keys
|
73
|
+
@folder_aliase_keys = @folder_aliases.keys
|
74
|
+
|
75
|
+
@all_files = @file_keys + @file_aliase_keys
|
76
|
+
@all_folders = @folder_keys + @folder_aliase_keys
|
77
|
+
end
|
78
|
+
|
79
|
+
def chunkify
|
80
|
+
return @contents.zip if @one_per_line
|
81
|
+
|
82
|
+
chunk_size = @contents.count
|
83
|
+
|
84
|
+
until in_line(chunk_size) || chunk_size <= 1
|
85
|
+
chunk_size -= 1
|
86
|
+
chunk = get_chunk(chunk_size)
|
87
|
+
end
|
88
|
+
|
89
|
+
chunk || [@contents]
|
90
|
+
end
|
91
|
+
|
92
|
+
def get_chunk(chunk_size)
|
93
|
+
chunk = @contents.each_slice(chunk_size).to_a
|
94
|
+
chunk.last += [''] * (chunk_size - chunk.last.count)
|
95
|
+
@max_widths = chunk.transpose.map { |c| c.map(&:length).max }
|
96
|
+
chunk
|
97
|
+
end
|
98
|
+
|
99
|
+
def in_line(chunk_size)
|
100
|
+
return false if @max_widths.sum + 6 * chunk_size > @screen_width
|
101
|
+
true
|
102
|
+
end
|
103
|
+
|
104
|
+
def display_report
|
105
|
+
print "\n Found #{@total_content_length} contents in directory "
|
106
|
+
.colorize(:white)
|
107
|
+
|
108
|
+
print File.expand_path(@input).to_s.colorize(:blue)
|
109
|
+
|
110
|
+
puts "\n\n\tFolders\t\t\t: #{@count[:folders]}"\
|
111
|
+
"\n\tRecognized files\t: #{@count[:recognized_files]}"\
|
112
|
+
"\n\tUnrecognized files\t: #{@count[:unrecognized_files]}"
|
113
|
+
.colorize(:white)
|
114
|
+
end
|
115
|
+
|
116
|
+
def fetch_string(content, key, color, increment)
|
117
|
+
@count[increment] += 1
|
118
|
+
value = increment == :folders ? @folders[key] : @files[key]
|
119
|
+
logo = value.gsub(/\\u[\da-f]{4}/i) { |m| [m[-4..-1].to_i(16)].pack('U') }
|
120
|
+
|
121
|
+
"#{logo} #{content}".colorize(color)
|
122
|
+
end
|
123
|
+
|
124
|
+
def load_from_yaml(filename, aliase=false)
|
125
|
+
filepath = File.join(File.dirname(__FILE__),"../yaml/#{filename}")
|
126
|
+
yaml = YAML.safe_load(File.read(filepath)).symbolize_keys
|
127
|
+
return yaml unless aliase
|
128
|
+
yaml
|
129
|
+
.to_a
|
130
|
+
.map! { |k, v| [k, v.to_sym] }
|
131
|
+
.to_h
|
132
|
+
end
|
133
|
+
|
134
|
+
def ls_line(chunk)
|
135
|
+
print "\n"
|
136
|
+
chunk.each_with_index do |content, i|
|
137
|
+
break if content.empty?
|
138
|
+
|
139
|
+
print " #{fetch_string(content, *options(content))}"
|
140
|
+
print Dir.exist?("#{@input}/#{content}") ? '/'.colorize(:blue) : ' '
|
141
|
+
print ' ' * (@max_widths[i] - content.length)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def options(content)
|
146
|
+
if Dir.exist?("#{@input}/#{content}")
|
147
|
+
key = content.to_sym
|
148
|
+
return %i[folder blue folders] unless @all_folders.include?(key)
|
149
|
+
key = @folder_aliases[key] unless @folder_keys.include?(key)
|
150
|
+
return [key, :blue, :folders]
|
151
|
+
end
|
152
|
+
|
153
|
+
key = content.split('.').last.downcase.to_sym
|
154
|
+
|
155
|
+
return %i[file yellow unrecognized_files] unless @all_files.include?(key)
|
156
|
+
|
157
|
+
key = @file_aliases[key] unless @file_keys.include?(key)
|
158
|
+
[key, :green, :recognized_files]
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
data/lib/colorls/version.rb
CHANGED
data/lib/yaml/file_aliases.yaml
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
apk: android
|
2
|
+
gradle: android
|
2
3
|
ds_store: apple
|
3
4
|
localized: apple
|
4
5
|
mp3: audio
|
@@ -17,10 +18,13 @@ gitignore_global: git
|
|
17
18
|
lhs: hs
|
18
19
|
bmp: image
|
19
20
|
gif: image
|
21
|
+
ico: image
|
20
22
|
jpeg: image
|
21
23
|
jpg: image
|
22
24
|
png: image
|
23
25
|
svg: image
|
26
|
+
jar: java
|
27
|
+
properties: json
|
24
28
|
markdown: md
|
25
29
|
mkd: md
|
26
30
|
rdoc: md
|
@@ -46,10 +50,13 @@ bashrc: shell
|
|
46
50
|
bash_history: shell
|
47
51
|
bash_profile: shell
|
48
52
|
sh: shell
|
53
|
+
fish: shell
|
49
54
|
zsh: shell
|
50
55
|
zsh-theme: shell
|
51
56
|
zshrc: shell
|
57
|
+
cls: tex
|
52
58
|
mp4: video
|
59
|
+
bat: windows
|
53
60
|
exe: windows
|
54
61
|
ini: windows
|
55
62
|
csv: xls
|
@@ -57,5 +64,6 @@ gsheet: xls
|
|
57
64
|
xlsx: xls
|
58
65
|
xul: xml
|
59
66
|
yaml: yml
|
67
|
+
gz: zip
|
60
68
|
rar: zip
|
61
|
-
tar: zip
|
69
|
+
tar: zip
|
data/lib/yaml/files.yaml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
ai: "\ue7b4"
|
2
|
-
android: "\
|
2
|
+
android: "\ue70e"
|
3
3
|
apple: "\uf179"
|
4
4
|
audio: "\uf001"
|
5
5
|
avro: "\ue60b"
|
@@ -20,10 +20,11 @@ file: "\uf15b"
|
|
20
20
|
font: "\uf031"
|
21
21
|
gform: "\uf298"
|
22
22
|
git: "\uf1d3"
|
23
|
-
go: "\
|
23
|
+
go: "\ue626"
|
24
24
|
hs: "\ue777"
|
25
25
|
html: "\uf13b"
|
26
26
|
image: "\uf1c5"
|
27
|
+
iml: "\ue7b5"
|
27
28
|
java: "\ue204"
|
28
29
|
js: "\ue74e"
|
29
30
|
json: "\ue60b"
|
@@ -31,6 +32,7 @@ less: "\ue758"
|
|
31
32
|
lua: "\ue620"
|
32
33
|
md: "\uf48a"
|
33
34
|
mustache: "\ue60f"
|
35
|
+
npmignore: "\ue71e"
|
34
36
|
pdf: "\uf1c1"
|
35
37
|
php: "\ue73d"
|
36
38
|
pl: "\ue769"
|
@@ -43,7 +45,10 @@ rdb: "\ue76d"
|
|
43
45
|
rss: "\uf09e"
|
44
46
|
scala: "\ue737"
|
45
47
|
shell: "\uf489"
|
48
|
+
sqlite3: "\ue7c4"
|
46
49
|
styl: "\ue600"
|
50
|
+
tex: "\ue600"
|
51
|
+
ts: "\ue628"
|
47
52
|
twig: "\ue61c"
|
48
53
|
txt: "\uf15c"
|
49
54
|
video: "\uf03d"
|
@@ -52,4 +57,4 @@ windows: "\uf17a"
|
|
52
57
|
xls: "\uf1c3"
|
53
58
|
xml: "\ue619"
|
54
59
|
yml: "\uf481"
|
55
|
-
zip: "\uf410"
|
60
|
+
zip: "\uf410"
|
data/lib/yaml/folders.yaml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colorls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Athitya
|
7
|
+
- Athitya Kumar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -112,20 +112,22 @@ description:
|
|
112
112
|
email:
|
113
113
|
- athityakumar@gmail.com
|
114
114
|
executables:
|
115
|
-
-
|
115
|
+
- colorls
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
119
|
- ".gitignore"
|
120
120
|
- ".rubocop.yml"
|
121
121
|
- ".travis.yml"
|
122
|
+
- CONTRIBUTING.md
|
122
123
|
- Gemfile
|
123
|
-
- LICENSE.
|
124
|
+
- LICENSE.md
|
124
125
|
- README.md
|
125
126
|
- Rakefile
|
126
127
|
- colorls.gemspec
|
127
|
-
- exe/
|
128
|
+
- exe/colorls
|
128
129
|
- lib/colorls.rb
|
130
|
+
- lib/colorls/core.rb
|
129
131
|
- lib/colorls/flags.rb
|
130
132
|
- lib/colorls/version.rb
|
131
133
|
- lib/yaml/file_aliases.yaml
|