strip cwd prefix './' from files (fd v8.3.0 '--strip-cwd-prefix')

main
bhagwan 3 years ago
parent 2d6967be4b
commit ccc9ee3e4f

@ -248,6 +248,12 @@ M.make_entry_file = function(opts, x)
return nil
end
end
-- fd v8.3 requires adding '--strip-cwd-prefix' to remove
-- the './' prefix, will not work with '--color=always'
-- https://github.com/sharkdp/fd/blob/master/CHANGELOG.md
if opts.strip_cwd_prefix == nil or opts.strip_cwd_prefix then
x = path.strip_cwd_prefix(x)
end
if opts.cwd and #opts.cwd > 0 then
-- TODO: does this work if there are ANSI escape codes in x?
x = path.relative(x, opts.cwd)

@ -11,6 +11,10 @@ M.starts_with_separator = function(path)
return path:find(M.separator()) == 1
end
M.strip_cwd_prefix = function(path)
return path:gsub("^."..M.separator(), "")
end
function M.tail(path)
local os_sep = string_byte(M.separator())

Loading…
Cancel
Save