mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-19 05:31:23 +02:00
add support for --non-human-readable flag
This commit is contained in:
parent
3ad436b533
commit
e231708f30
2 changed files with 9 additions and 2 deletions
|
@ -140,6 +140,7 @@ module ColorLS
|
|||
@show_group = long_style_options.key?(:show_group) ? long_style_options[:show_group] : true
|
||||
@show_user = long_style_options.key?(:show_user) ? long_style_options[:show_user] : true
|
||||
@show_symbol_dest = long_style_options.key?(:show_symbol_dest) ? long_style_options[:show_symbol_dest] : false
|
||||
@show_human_readable_size = long_style_options.key?(:human_readable_size) ? long_style_options[:human_readable_size] : true
|
||||
end
|
||||
|
||||
def init_git_status(show_git)
|
||||
|
@ -254,7 +255,9 @@ module ColorLS
|
|||
end
|
||||
|
||||
def size_info(filesize)
|
||||
size = Filesize.new(filesize).pretty.split
|
||||
filesize = Filesize.new(filesize)
|
||||
size = @show_human_readable_size ? filesize.pretty : filesize.to_s
|
||||
size = size.split
|
||||
size = "#{size[0][0..-4].rjust(4,' ')} #{size[1].ljust(3,' ')}"
|
||||
return size.colorize(@colors[:file_large]) if filesize >= 512 * (1024 ** 2)
|
||||
return size.colorize(@colors[:file_medium]) if filesize >= 128 * (1024 ** 2)
|
||||
|
|
|
@ -184,7 +184,8 @@ module ColorLS
|
|||
show_user: true,
|
||||
time_style: '',
|
||||
hard_links_count: true,
|
||||
show_symbol_dest: false
|
||||
show_symbol_dest: false,
|
||||
human_readable_size: true
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -199,6 +200,9 @@ module ColorLS
|
|||
long_style_options[:hard_links_count] = false
|
||||
end
|
||||
long_style_options = get_long_style_symlink_options(options, long_style_options)
|
||||
options.on('--nh', '--non-human-readable', 'show file sizes in bytes only') do
|
||||
long_style_options[:human_readable_size] = false
|
||||
end
|
||||
@opts[:long_style_options] = long_style_options
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue