Skip to content

Commit 68de23e

Browse files
author
skywind3000
committed
v1.5.7: rename $_ZL_FZF_SORT to $_ZL_INT_SORT it will affect both -i and -I.
1 parent 5ea08c5 commit 68de23e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ As you see, z.lua is the fastest one and requires less resource.
458458

459459
## History
460460

461+
- 1.5.7 (2019-02-21): rename `$_ZL_FZF_SORT` to `$_ZL_INT_SORT` it will affect both `-i` and `-I`.
461462
- 1.5.6 (2019-02-20): set `$_ZL_FZF_SORT` to 1 to sort directories by alphabet in fzf.
462463
- 1.5.5 (2019-02-20): `$_ZL_FZF_FLAG` can be used to override fzf flags, default to "+s -e".
463464
- 1.5.4 (2019-02-19): fixed: file/path existence detection fails on read-only fs (closed [#49](https://github.com/skywind3000/z.lua/issues/49) by [@contrun](https://github.com/contrun)).

z.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- z.lua - a cd command that learns, by skywind 2018, 2019
55
-- Licensed under MIT license.
66
--
7-
-- Version 1.5.6, Last Modified: 2019/02/20 23:30
7+
-- Version 1.5.7, Last Modified: 2019/02/21 11:07
88
--
99
-- * 10x faster than fasd and autojump, 3x faster than z.sh
1010
-- * available for posix shells: bash, zsh, sh, ash, dash, busybox
@@ -770,6 +770,10 @@ end
770770
-----------------------------------------------------------------------
771771
function os.environ(name, default)
772772
local value = os.getenv(name)
773+
if os.envmap ~= nil and type(os.envmap) == 'table' then
774+
local t = os.envmap[name]
775+
value = (t ~= nil and type(t) == 'string') and t or value
776+
end
773777
if value == nil then
774778
return default
775779
elseif type(default) == 'boolean' then
@@ -1427,6 +1431,9 @@ function z_cd(patterns)
14271431
elseif Z_INTERACTIVE == 0 then
14281432
return M[1].name
14291433
end
1434+
if os.environ('_ZL_INT_SORT', false) then
1435+
table.sort(M, function (a, b) return a.name < b.name end)
1436+
end
14301437
local retval = nil
14311438
if Z_INTERACTIVE == 1 then
14321439
PRINT_MODE = '<stderr>'
@@ -1463,9 +1470,6 @@ function z_cd(patterns)
14631470
tmpname = os.environ('TMP', '') .. '\\zlua_' .. tmpname .. '.txt'
14641471
cmd = 'type "' .. tmpname .. '" | ' .. cmd
14651472
end
1466-
if os.environ('_ZL_FZF_SORT', false) then
1467-
table.sort(M, function (a, b) return a.name < b.name end)
1468-
end
14691473
PRINT_MODE = tmpname
14701474
z_print(M, true, false)
14711475
retval = os.call(cmd)

0 commit comments

Comments
 (0)