|
4 | 4 | -- z.lua - a cd command that learns, by skywind 2018, 2019 |
5 | 5 | -- Licensed under MIT license. |
6 | 6 | -- |
7 | | --- Version 1.5.6, Last Modified: 2019/02/20 23:30 |
| 7 | +-- Version 1.5.7, Last Modified: 2019/02/21 11:07 |
8 | 8 | -- |
9 | 9 | -- * 10x faster than fasd and autojump, 3x faster than z.sh |
10 | 10 | -- * available for posix shells: bash, zsh, sh, ash, dash, busybox |
|
770 | 770 | ----------------------------------------------------------------------- |
771 | 771 | function os.environ(name, default) |
772 | 772 | 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 |
773 | 777 | if value == nil then |
774 | 778 | return default |
775 | 779 | elseif type(default) == 'boolean' then |
@@ -1427,6 +1431,9 @@ function z_cd(patterns) |
1427 | 1431 | elseif Z_INTERACTIVE == 0 then |
1428 | 1432 | return M[1].name |
1429 | 1433 | 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 |
1430 | 1437 | local retval = nil |
1431 | 1438 | if Z_INTERACTIVE == 1 then |
1432 | 1439 | PRINT_MODE = '<stderr>' |
@@ -1463,9 +1470,6 @@ function z_cd(patterns) |
1463 | 1470 | tmpname = os.environ('TMP', '') .. '\\zlua_' .. tmpname .. '.txt' |
1464 | 1471 | cmd = 'type "' .. tmpname .. '" | ' .. cmd |
1465 | 1472 | 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 |
1469 | 1473 | PRINT_MODE = tmpname |
1470 | 1474 | z_print(M, true, false) |
1471 | 1475 | retval = os.call(cmd) |
|
0 commit comments