mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-19 05:31:23 +02:00
Merge pull request #164 from avdv/collation
Proper sorting according to current LANG / locale
This commit is contained in:
commit
3af19cc54a
6 changed files with 8 additions and 2 deletions
2
Rakefile
2
Rakefile
|
@ -17,7 +17,7 @@ file 'man/colorls.1' => ['man/colorls.1.ronn', 'lib/colorls/flags.rb'] do
|
|||
|
||||
flags = ColorLS::Flags.new
|
||||
attributes = {
|
||||
date: Time.now,
|
||||
date: Date.iso8601(`git log -1 --pretty=format:%aI -- man/colorls.1`),
|
||||
manual: 'colorls Manual',
|
||||
organization: "colorls #{ColorLS::VERSION}"
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ Gem::Specification.new do |spec|
|
|||
|
||||
spec.post_install_message = ColorLS::POST_INSTALL_MESSAGE
|
||||
|
||||
spec.add_runtime_dependency 'clocale'
|
||||
spec.add_runtime_dependency 'filesize'
|
||||
spec.add_runtime_dependency 'manpages'
|
||||
spec.add_runtime_dependency 'rainbow'
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'colorls'
|
||||
|
||||
ColorLS::Flags.new(*ARGV).process
|
||||
true
|
||||
|
|
|
@ -2,6 +2,7 @@ require 'yaml'
|
|||
require 'etc'
|
||||
require 'filesize'
|
||||
require 'rainbow/ext/string'
|
||||
require 'clocale'
|
||||
|
||||
require 'colorls/core'
|
||||
require 'colorls/flags'
|
||||
|
|
|
@ -117,7 +117,7 @@ module ColorLS
|
|||
when :size
|
||||
@contents.sort_by! { |a| -File.size(File.join(path, a)) }
|
||||
else
|
||||
@contents.sort! { |a, b| a.casecmp(b) }
|
||||
@contents.sort_by! { |a| CLocale.strxfrm(a) }
|
||||
end
|
||||
@contents.reverse! if @reverse
|
||||
end
|
||||
|
|
|
@ -34,6 +34,9 @@ module ColorLS
|
|||
end
|
||||
|
||||
def process
|
||||
# initialize locale from environment
|
||||
CLocale.setlocale(CLocale::LC_COLLATE, '')
|
||||
|
||||
return Core.new(@opts).ls if @args.empty?
|
||||
@args.sort!.each_with_index do |path, i|
|
||||
next STDERR.puts "\n Specified path '#{path}' doesn't exist.".colorize(:red) unless File.exist?(path)
|
||||
|
|
Loading…
Reference in a new issue