From a9913055328dd10a2b02e07f2eca520e491099b0 Mon Sep 17 00:00:00 2001 From: skywind3000 Date: Sun, 10 Feb 2019 21:55:56 +0800 Subject: [PATCH] improve posix compatibility --- README.md | 2 ++ z.lua | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index aa6c6cb..c029a12 100644 --- a/README.md +++ b/README.md @@ -397,6 +397,7 @@ awk -F '\t' '{print $2 "|" $1 "|" 0}' $FN >> ~/.zlua ## History +- 1.4.5 (2019-02-10): improve bash fzf completion and posix compatibility. - 1.4.4 (2019-02-10): supports legacy posix shells like ksh, init with `z.lua --init posix legacy`. - 1.4.3 (2019-02-08): fixed minor issues. - 1.4.2 (2019-02-06): you can disabled path validation by `$_ZL_NO_CHECK`, and use `z --purge` to clear bad paths manually. @@ -430,6 +431,7 @@ This project needs help for the tasks below: - Thanks to [@vigneshwaranr](https://github.com/vigneshwaranr) and [@shyiko](https://github.com/shyiko) for inspiring me the backward jumping. - 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. And many others. diff --git a/z.lua b/z.lua index 7cd7014..491dfd1 100755 --- a/z.lua +++ b/z.lua @@ -4,7 +4,7 @@ -- z.lua - a cd command that learns, by skywind 2018, 2019 -- Licensed under MIT license. -- --- Version 1.4.4, Last Modified: 2019/02/10 15:07 +-- Version 1.4.5, Last Modified: 2019/02/10 21:53 -- -- * 10x faster than fasd and autojump, 3x faster than z.sh -- * available for posix shells: bash, zsh, sh, ash, dash, busybox @@ -1910,8 +1910,11 @@ function z_shell_init(opts) print('ZLUA_SCRIPT="' .. os.scriptname() .. '"') print('ZLUA_LUAEXE="' .. os.interpreter() .. '"') print('') - if not opts.legacy then + if not opts.posix then print(script_zlua) + elseif not opts.legacy then + local script = script_zlua:gsub('builtin ', '') + print(script) else local script = script_zlua:gsub('local ', ''):gsub('builtin ', '') print(script) @@ -1953,7 +1956,6 @@ function z_shell_init(opts) end print(script) end - print('_ZL_NO_BUILTIN_CD=1') else if prompt_hook then print('if [ -n "$BASH_VERSION" ]; then') @@ -1970,7 +1972,7 @@ function z_shell_init(opts) -- print(script_complete_zsh) print('else') print(once and script_init_posix_once or script_init_posix) - print('_ZL_NO_BUILTIN_CD=1') + print('builtin() { cd "$2"; }') print('fi') end end @@ -2097,7 +2099,7 @@ function z_fish_init(opts) print('set -x _ZL_MATCH_MODE 1') end if opts.echo then - print('set -x _ZL_ECHO 1') + print('set _ZL_ECHO 1') end if opts.nc then print('set -x _ZL_NO_CHECK 1')