From db92fa0a1cfb6c091e2e925e07c2b297e65a5d6a Mon Sep 17 00:00:00 2001 From: skywind3000 Date: Wed, 20 Feb 2019 20:24:24 +0800 Subject: [PATCH] new "$_ZL_FZF_SORT" to sort directories by alphabet in fzf --- README.md | 1 + z.lua | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a42990a..992d027 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.6 (2019-02-20): new `$_ZL_FZF_SORT` 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)). - 1.5.3 (2019-02-17): new `$_ZL_FZF_FLAG` for passing additional flags to fzf, add `-e` argument to fzf. diff --git a/z.lua b/z.lua index 2e01d7a..17537a3 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.5, Last Modified: 2019/02/20 12:07 +-- Version 1.5.6, Last Modified: 2019/02/20 20:20 -- -- * 10x faster than fasd and autojump, 3x faster than z.sh -- * available for posix shells: bash, zsh, sh, ash, dash, busybox @@ -1463,6 +1463,9 @@ 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)