Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8e92e0216 | ||
|
|
e2cce39ee4 | ||
|
|
3c88f8d8fa | ||
|
|
786225005c | ||
|
|
481c1774ed | ||
|
|
35e1199eff | ||
|
|
99dbe7b677 | ||
|
|
c88746629b | ||
|
|
336e95b05a |
@@ -35,7 +35,7 @@ From people using z.lua:
|
||||
- Integrated with FZF (optional) for interactive selection and completion.
|
||||
- Quickly go back to a parent directory instead of typing "cd ../../..".
|
||||
- Corresponding experience in different shells and operating systems.
|
||||
- Compatible with Lua 5.1, 5.2 and 5.3+
|
||||
- Compatible with Lua (5.1, 5.2, 5.3+) and luajit.
|
||||
- Self contained, distributed as a single `z.lua` script, no other dependence.
|
||||
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 9.0 KiB |
BIN
images/fzf.png
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 8.5 KiB |
BIN
images/mru.png
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 10 KiB |
BIN
images/step1.png
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 7.5 KiB |
BIN
images/step2.png
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 5.7 KiB |
BIN
images/step3.png
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 3.6 KiB |
BIN
images/step4.png
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 3.4 KiB |
@@ -27,6 +27,8 @@ end
|
||||
if test -e $_zlua_dir/z.lua
|
||||
if type -q lua
|
||||
lua $_zlua_dir/z.lua --init fish enhanced once echo | source
|
||||
else if type -q luajit
|
||||
luajit $_zlua_dir/z.lua --init fish enhanced once echo | source
|
||||
else if type -q lua5.3
|
||||
lua5.3 $_zlua_dir/z.lua --init fish enhanced once echo | source
|
||||
else if type -q lua5.2
|
||||
|
||||
8
z.cmd
@@ -120,8 +120,12 @@ rem -- Exploits variable expansion and the pushd stack to set the current
|
||||
rem -- directory without leaking a pushd.
|
||||
popd
|
||||
setlocal
|
||||
set NewPath=%CD%
|
||||
endlocal & popd & cd /d "%NewPath%"
|
||||
set "NewPath=%CD%"
|
||||
set "CDCmd=cd /d"
|
||||
if /i not "%_ZL_CD%"=="" (
|
||||
set "CDCmd=%_ZL_CD%"
|
||||
)
|
||||
endlocal & popd & %CDCmd% "%NewPath%"
|
||||
|
||||
:end
|
||||
echo.
|
||||
|
||||
17
z.lua
@@ -1,10 +1,10 @@
|
||||
#! /usr/bin/env lua
|
||||
--=====================================================================
|
||||
--
|
||||
-- z.lua - a cd command that learns, by skywind 2018, 2019, 2020, 2021
|
||||
-- z.lua - a cd command that learns, by skywind 2018-2022
|
||||
-- Licensed under MIT license.
|
||||
--
|
||||
-- Version 1.8.12, Last Modified: 2021/02/15 00:05
|
||||
-- Version 1.8.15, Last Modified: 2022/03/27 21:38
|
||||
--
|
||||
-- * 10x faster than fasd and autojump, 3x faster than z.sh
|
||||
-- * available for posix shells: bash, zsh, sh, ash, dash, busybox
|
||||
@@ -527,13 +527,16 @@ function os.path.abspath(path)
|
||||
return test
|
||||
end
|
||||
end
|
||||
for _, python in pairs({'python', 'python2', 'python3'}) do
|
||||
for _, python in pairs({'python3', 'python2', 'python'}) do
|
||||
local s = 'sys.stdout.write(os.path.abspath(sys.argv[1]))'
|
||||
local s = '-c "import os, sys;' .. s .. '" \'' .. path .. '\''
|
||||
local s = python .. ' ' .. s
|
||||
local test = os.path.which(python)
|
||||
if test ~= nil and test ~= '' then
|
||||
return os.call(s)
|
||||
test = os.call(s)
|
||||
if test ~= nil and test ~= '' then
|
||||
return test
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2563,7 +2566,11 @@ goto end
|
||||
popd
|
||||
setlocal
|
||||
set "NewPath=%CD%"
|
||||
endlocal & popd & cd /d "%NewPath%"
|
||||
set "CDCmd=cd /d"
|
||||
if /i not "%_ZL_CD%"=="" (
|
||||
set "CDCmd=%_ZL_CD%"
|
||||
)
|
||||
endlocal & popd & %CDCmd% "%NewPath%"
|
||||
:end
|
||||
]]
|
||||
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
ZLUA_SCRIPT="${0:A:h}/z.lua"
|
||||
|
||||
[[ -n "$ZLUA_EXEC" ]] && [[ ! -x "$ZLUA_EXEC" ]] && ZLUA_EXEC=""
|
||||
if [[ -n "$ZLUA_EXEC" ]] && ! which "$ZLUA_EXEC" &>/dev/null; then
|
||||
echo "$ZLUA_EXEC not found"
|
||||
ZLUA_EXEC=""
|
||||
fi
|
||||
|
||||
# search lua executable
|
||||
if [[ -z "$ZLUA_EXEC" ]]; then
|
||||
for lua in lua lua5.3 lua5.2 lua5.1; do
|
||||
for lua in lua luajit lua5.4 lua5.3 lua5.2 lua5.1; do
|
||||
ZLUA_EXEC="$(command -v "$lua")"
|
||||
[[ -n "$ZLUA_EXEC" ]] && break
|
||||
done
|
||||
|
||||