1
0
mirror of https://github.com/skywind3000/z.lua synced 2026-03-14 11:49:48 +00:00

update path calculation

This commit is contained in:
skywind3000
2018-11-22 00:00:22 +08:00
parent b478abcf5e
commit 24fe2d4a6e
2 changed files with 17 additions and 9 deletions

View File

@@ -67,6 +67,17 @@ z -e foo # echo the best match, don't cd
- set `$_ZL_NO_PROMPT_COMMAND` if you're handling PROMPT_COMMAND yourself.
- set `$_ZL_EXCLUDE_DIRS` to an array of directories to exclude.
## Credit
Licensed under MIT license.
Releated projects:
- [rupa/z](https://github.com/rupa/z): origin z.sh implementation
- [JannesMeyer/z.ps](https://github.com/JannesMeyer/z.ps): z for powershell
## License
Licensed under MIT license.

13
z.lua
View File

@@ -607,15 +607,12 @@ function data_save(filename, M)
fp = io.open(filename, 'w')
else
math.random_init()
tmpname = filename .. '.' .. math.random_string(8)
tmpname = tmpname .. tostring(os.time())
local rnd = os.getenv('_ZL_RANDOM')
if rnd ~= nil then
tmpname = tmpname .. '' ..rnd
end
tmpname = filename .. '.' .. math.random_string(6)
local sub = (os.tmpname()):sub(-6, -1):gsub('[\\/:~]', '')
local ppid = os.getenv('PPID')
tmpname = tmpname .. sub .. (ppid and ppid or '')
tmpname = tmpname .. sub .. tostring(os.time())
local rnd = os.getenv('_ZL_RANDOM')
tmpname = tmpname .. '' .. (rnd and rnd or '')
-- print('tmpname: '..tmpname)
fp = io.open(tmpname, 'w')
end
if fp == nil then