mirror of
https://github.com/skywind3000/z.lua
synced 2026-03-21 23:29:48 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c36d55698 | ||
|
|
bdab27db1b | ||
|
|
e08f5beca4 |
@@ -458,6 +458,7 @@ As you see, z.lua is the fastest one and requires less resource.
|
||||
|
||||
## History
|
||||
|
||||
- 1.7.3 (2019-09-07): use [lua-filesystem](http://keplerproject.github.io/luafilesystem/) package if possible when `$_ZL_USE_LFS` is `1`.
|
||||
- 1.7.2 (2019-08-01): Improve bash/zsh shell compatibility by [@barlik](https://github.com/barlik).
|
||||
- 1.7.1 (2019-06-07): Fixed: `$_ZL_DATA` failure on Linux sometimes.
|
||||
- 1.7.0 (2019-03-09): Support [ranger](https://github.com/skywind3000/z.lua/wiki/FAQ#how-to-integrate-zlua-to-ranger-), fix ReplaceFile issue in luajit (windows).
|
||||
@@ -512,6 +513,7 @@ This project needs help for the tasks below:
|
||||
- Thanks to [@TeddyDD](https://github.com/TeddyDD) for Fish Shell porting.
|
||||
- Thanks to [@manhong2112](https://github.com/manhong2112) for Power Shell porting.
|
||||
- Thanks to [@BarbUk](https://github.com/BarbUk) for fzf completion in Bash.
|
||||
- Thanks to [@barlik](https://github.com/barlik) for many improvements.
|
||||
|
||||
And many others.
|
||||
|
||||
|
||||
34
z.lua
34
z.lua
@@ -4,7 +4,7 @@
|
||||
-- z.lua - a cd command that learns, by skywind 2018, 2019
|
||||
-- Licensed under MIT license.
|
||||
--
|
||||
-- Version 1.7.2, Last Modified: 2019/08/01 19:45
|
||||
-- Version 1.7.3, Last Modified: 2019/09/06 17:27
|
||||
--
|
||||
-- * 10x faster than fasd and autojump, 3x faster than z.sh
|
||||
-- * available for posix shells: bash, zsh, sh, ash, dash, busybox
|
||||
@@ -74,6 +74,7 @@
|
||||
-- set $_ZL_MAXAGE to define a aging threshold (default is 5000).
|
||||
-- set $_ZL_MATCH_MODE to 1 to enable enhanced matching mode.
|
||||
-- set $_ZL_NO_CHECK to 1 to disable path validation. z --purge to clear.
|
||||
-- set $_ZL_USE_LFS to 1 to use lua-filesystem package
|
||||
--
|
||||
--=====================================================================
|
||||
|
||||
@@ -548,6 +549,9 @@ end
|
||||
-- file or path exists
|
||||
-----------------------------------------------------------------------
|
||||
function os.path.exists(name)
|
||||
if name == '/' then
|
||||
return true
|
||||
end
|
||||
local ok, err, code = os.rename(name, name)
|
||||
if not ok then
|
||||
if code == 13 then
|
||||
@@ -2539,7 +2543,33 @@ end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- testing case
|
||||
-- LFS optimize
|
||||
-----------------------------------------------------------------------
|
||||
os.lfs = {}
|
||||
os.lfs.enable = os.getenv('_ZL_USE_LFS')
|
||||
if os.lfs.enable ~= nil then
|
||||
local m = string.lower(os.lfs.enable)
|
||||
if (m == '1' or m == 'yes' or m == 'true' or m == 't') then
|
||||
os.lfs.status, os.lfs.pkg = pcall(require, 'lfs')
|
||||
if os.lfs.status then
|
||||
local lfs = os.lfs.pkg
|
||||
os.path.exists = function (name)
|
||||
return lfs.attributes(name) and true or false
|
||||
end
|
||||
os.path.isdir = function (name)
|
||||
local mode = lfs.attributes(name)
|
||||
if not mode then
|
||||
return false
|
||||
end
|
||||
return (mode.mode == 'directory') and true or false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- program entry
|
||||
-----------------------------------------------------------------------
|
||||
if not pcall(debug.getlocal, 4, 1) then
|
||||
-- main script
|
||||
|
||||
Reference in New Issue
Block a user