Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(483): adds support for --without-icons feature flag #552

Merged
merged 4 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/colorls/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Core
def initialize(all: false, sort: false, show: false,
mode: nil, show_git: false, almost_all: false, colors: [], group: nil,
reverse: false, hyperlink: false, tree_depth: nil, show_inode: false,
indicator_style: 'slash', long_style_options: {})
indicator_style: 'slash', long_style_options: {}, icons: true)
@count = {folders: 0, recognized_files: 0, unrecognized_files: 0}
@all = all
@almost_all = almost_all
Expand All @@ -48,6 +48,7 @@ def initialize(all: false, sort: false, show: false,
@hard_links_count = long_style_options.key?(:hard_links_count) ? long_style_options[:hard_links_count] : true
# how much characters an item occupies besides its name
@additional_chars_per_item = 12 + (@show_git ? 4 : 0) + (@show_inode ? 10 : 0)
@icons = icons

init_colors colors

Expand Down Expand Up @@ -341,7 +342,10 @@ def fetch_string(content, key, color, increment)
logo = value.gsub(/\\u[\da-f]{4}/i) { |m| [m[-4..].to_i(16)].pack('U') }
name = @hyperlink ? make_link(content) : content.show
name += content.directory? && @indicator_style != 'none' ? '/' : ' '
entry = "#{out_encode(logo)} #{out_encode(name)}"
entry = "#{out_encode(name)}"
if @icons
entry = "#{out_encode(logo)} #{out_encode(name)}"
end
entry = entry.bright if !content.directory? && content.executable?

"#{inode(content)} #{long_info(content)} #{git_info(content)} #{entry.colorize(color)}#{symlink_info(content)}"
Expand Down
1 change: 1 addition & 0 deletions lib/colorls/flags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def add_format_options(options)
end
options.on('-x', 'list entries by lines instead of by columns') { @opts[:mode] = :horizontal }
options.on('-C', 'list entries by columns instead of by lines') { @opts[:mode] = :vertical }
options.on('--without-icons', 'list entries without icons') { @opts[:icons] = false }
end

def default_long_style_options
Expand Down