On Windows, MRI Ruby uses the `FindFirstFileW` et. al. kind of functions with
wide character paths and constantly converts from multi-byte to wide character
encoding back and forth when calling any methods on `File` or `Dir`.
This means that when using `Encoding::ASCII_8BIT` for reading directory entries,
that this does not round trip properly, if a file name contains unicode
characters. That is because Ruby assumes the path string is encoded in Windows
Codepage 1252[1].
* skip symlink test if files were checked out from git as textual symlinks on
Windows
* use UTF-8 encoding on Windows, since this properly round-trips between
multi-byte and wide character encoding
* travis: windows job no longer is allowed to fail
[1]: 946cd6c534/win32/file.c (L131-L134)
A *file* is assigned a generic icon / glyph in `files.yaml`, so looking up
`:file` in the corresponding hash always succeeds, but `:file` is also used as
the fallback key if a file's extension is not recognized.
First determining the color and group of a given file before falling back to
the `:file` key fixes this issue.
* Style/MultilineWhenThen: Do not use then for multiline when statement
* Style/StringConcatenation: Prefer string interpolation to string concatenation
* Style/OptionalBooleanParameter: Use keyword arguments when defining method with boolean argument
* Style/GlobalStdStream: Use $stderr instead of STDERR
* Style/GlobalStdStream: Use $stdout instead of STDOUT
When trying to `require` a gem running in an unlinked directory, an exception is
thrown because `Dir.pwd` is called (see rubygems/rubygems#3087).
Until the fix lands in an official release, we monkey patch `Dir.pwd` to return
'/' if a `Errno::ENOENT` exception is raised while loading the colorls gem.
This should work for all Unixes. On Windows, this error cannot happen since you
cannot unlink a directory which is still in use by a process.
Fixes#351.
On Unix systems the encoding of file names is specified by the user via the
locale settings.
In order to avoid encoding problems simply read file names in ASCII 8 bit
encoding and try to convert to the external encoding while replacing undefined
characters.
Also, does not show an icon if the external encoding does not support it and
shows a `=` instead of a check mark for git status.
Fixes#352.
git does not report any status for empty directories, and it also does not
report any status for directories without any modified, untracked or ignored
files.
To correctly show the status, we need to check whether the directory is empty if
git did not report any status codes. When empty, show it as "not interesting",
otherwise the "no changes" green check mark is shown.
Note, I am specifically not using the untracked marker, as that would mean there
is some interesting file inside the directory which could be added.
Fixes#334.
```
lib/colorls/flags.rb:50: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
lib/colorls/core.rb:5: warning: The called method `initialize is defined here
```
This fixes the misalignment of files in a long listing when some files have a
different number of characters in the links column.
Instead of iterating three times over the @contents array, in order to compute
the sizes of the variant columns, use a single loop to compute the maximum size
for each column in a one pass.
* add and wire up `VerticalLayout` which is now the default
* adapt flags spec to use single-column layout for testing sort order
since the output is hard to verify when in vertical format
Fixes#189.
* add `Layout` base class which contains the base (binary) algorithm
for finding the maximum amount of columns fitting the given limit
* add `HorizontalLayout` and use it in `Core`
* add `SingleColumnLayout` and use it in `Core`
The git status is only computed for the given directory and is stored as
a Hash mapping relative paths to their mode string.
For a directory, the git status is comprised of all the statuses of its files
itself and all its sub directories.
The current directory's prefix is just an empty string matching all files inside
the `@git_status` Hash.
Asking for the status of the parent directory is pointless, we do not compute it
(yet).
* make `-h` an alias for `--human-readable`
* both options are simply ignored when used with an argument or another option
* running `colorls -h` still shows the help text since just as before
Using the `--show-prefix` option for `git ref-parse` simplifies determining the
status for the child items.
Previsouly, `File.realdirpath` was used to determine an absolute path, but this
method returns a path without symlinks. This caused status to be reported about
the link target instead of the symlink.
It reached EOL on 20th Jun 2018 and no longer receives patches.
* set required Ruby version to >= 2.3 in spec file
* set rubocop's TargetRubyVersion to 2.3 and fix all the offenses
Both are also supported by GNU ls, although currently not all formats are
supported.
This change lays ground for implementing column based formatting and also
supports using a pager with colorls keeping the formatting intact:
`colorls --color -x | less --tabs=4 -RFX`
This option works the same as for GNU ls, although if not specified colorization
is on by default (the `auto` mode).
Using `--color` is equivalent to `--color=always`.
This generates `file://` links using ANSI escape sequences which opens the
given file using the default application for the file type on your system.
A terminal emulator supporting hyperlinks is required, otherwise the links
will be ignored.
These special permission bits should cause the executable bit in the current
group to be replaced with an uppercase letter if the executable bit itself is
*not* set, with a lower case character otherwise.
In a long listing, the user was only shown when owning the file. Originally, the
user was only colorized when owning the file.
Change that to always colorize the user using the defined `:user` color.
Fixes#187.
In the `-z` git status format, a NUL follows each file name. When files are
renamed, the status field is followed by a space, the "to" path, a NUL
character, the "from" path and a terminating NUL.
This fixes#185.
* no longer traverse complete directory trees to determine git status for
directories
* properly report status for folders with changed files
* skip the parent folder since we do not have git status about it
* add `--sort=WORD` option, which sorts by modification "time" or not at all
* add short option `-U` to mean `--sort=none` (`ls` compatibility)
* `-t` now has the same effect as `--sort=time` which is also mentioned in the
post install mesage
* add checks for `--sort=time` and `--sort=none` to .travis.yml