Skip to content

Commit

Permalink
v1.5.7: rename $_ZL_FZF_SORT to $_ZL_INT_SORT it will affect both…
Browse files Browse the repository at this point in the history
… `-i` and `-I`.
  • Loading branch information
skywind3000 committed Feb 21, 2019
1 parent 5ea08c5 commit 68de23e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ As you see, z.lua is the fastest one and requires less resource.

## History

- 1.5.7 (2019-02-21): rename `$_ZL_FZF_SORT` to `$_ZL_INT_SORT` it will affect both `-i` and `-I`.
- 1.5.6 (2019-02-20): set `$_ZL_FZF_SORT` to 1 to sort directories by alphabet in fzf.
- 1.5.5 (2019-02-20): `$_ZL_FZF_FLAG` can be used to override fzf flags, default to "+s -e".
- 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)).
Expand Down
12 changes: 8 additions & 4 deletions z.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-- z.lua - a cd command that learns, by skywind 2018, 2019
-- Licensed under MIT license.
--
-- Version 1.5.6, Last Modified: 2019/02/20 23:30
-- Version 1.5.7, Last Modified: 2019/02/21 11:07
--
-- * 10x faster than fasd and autojump, 3x faster than z.sh
-- * available for posix shells: bash, zsh, sh, ash, dash, busybox
Expand Down Expand Up @@ -770,6 +770,10 @@ end
-----------------------------------------------------------------------
function os.environ(name, default)
local value = os.getenv(name)
if os.envmap ~= nil and type(os.envmap) == 'table' then
local t = os.envmap[name]
value = (t ~= nil and type(t) == 'string') and t or value
end
if value == nil then
return default
elseif type(default) == 'boolean' then
Expand Down Expand Up @@ -1427,6 +1431,9 @@ function z_cd(patterns)
elseif Z_INTERACTIVE == 0 then
return M[1].name
end
if os.environ('_ZL_INT_SORT', false) then
table.sort(M, function (a, b) return a.name < b.name end)
end
local retval = nil
if Z_INTERACTIVE == 1 then
PRINT_MODE = '<stderr>'
Expand Down Expand Up @@ -1463,9 +1470,6 @@ function z_cd(patterns)
tmpname = os.environ('TMP', '') .. '\\zlua_' .. tmpname .. '.txt'
cmd = 'type "' .. tmpname .. '" | ' .. cmd
end
if os.environ('_ZL_FZF_SORT', false) then
table.sort(M, function (a, b) return a.name < b.name end)
end
PRINT_MODE = tmpname
z_print(M, true, false)
retval = os.call(cmd)
Expand Down

0 comments on commit 68de23e

Please sign in to comment.