From 68de23ecef0deb6967deafd65b94d634ba487f30 Mon Sep 17 00:00:00 2001 From: skywind3000 Date: Thu, 21 Feb 2019 11:15:02 +0800 Subject: [PATCH] v1.5.7: rename `$_ZL_FZF_SORT` to `$_ZL_INT_SORT` it will affect both `-i` and `-I`. --- README.md | 1 + z.lua | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a486b45..533f1f4 100644 --- a/README.md +++ b/README.md @@ -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)). diff --git a/z.lua b/z.lua index c7eb902..97b0599 100755 --- a/z.lua +++ b/z.lua @@ -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 @@ -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 @@ -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 = '' @@ -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)