From 24fe2d4a6ec56d3a9359bdbacfe112cc381e8a12 Mon Sep 17 00:00:00 2001 From: skywind3000 Date: Thu, 22 Nov 2018 00:00:22 +0800 Subject: [PATCH] update path calculation --- README.md | 13 ++++++++++++- z.lua | 13 +++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7634d1d..1818b19 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file +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. + diff --git a/z.lua b/z.lua index a6c39f1..29e252d 100644 --- a/z.lua +++ b/z.lua @@ -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