Skip to content

Commit 788c0f4

Browse files
author
skywind3000
committed
new --init option clean to skip hooks
1 parent d615051 commit 788c0f4

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

z.lua

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- z.lua - a cd command that learns, by skywind 2018, 2019, 2020
55
-- Licensed under MIT license.
66
--
7-
-- Version 1.8.5, Last Modified: 2020/03/05 18:08
7+
-- Version 1.8.6, Last Modified: 2020/03/17 16:32
88
--
99
-- * 10x faster than fasd and autojump, 3x faster than z.sh
1010
-- * available for posix shells: bash, zsh, sh, ash, dash, busybox
@@ -2211,7 +2211,6 @@ fi
22112211
]]
22122212

22132213

2214-
22152214
-----------------------------------------------------------------------
22162215
-- initialize bash/zsh
22172216
----------------------------------------------------------------------
@@ -2232,6 +2231,10 @@ function z_shell_init(opts)
22322231
local prompt_hook = (not os.environ("_ZL_NO_PROMPT_COMMAND", false))
22332232
local once = os.environ("_ZL_ADD_ONCE", false) or opts.once ~= nil
22342233

2234+
if opts.clean ~= nil then
2235+
prompt_hook = false
2236+
end
2237+
22352238
if opts.bash ~= nil then
22362239
if prompt_hook then
22372240
if once then
@@ -2401,11 +2404,17 @@ function z_fish_init(opts)
24012404
print('set -x ZLUA_SCRIPT "' .. os.scriptname() .. '"')
24022405
print('set -x ZLUA_LUAEXE "' .. os.interpreter() .. '"')
24032406
local once = (os.getenv("_ZL_ADD_ONCE") ~= nil) or opts.once ~= nil
2407+
local prompt_hook = (not os.environ("_ZL_NO_PROMPT_COMMAND", false))
2408+
if opts.clean ~= nil then
2409+
prompt_hook = false
2410+
end
24042411
print(script_zlua_fish)
2405-
if once then
2406-
print(script_init_fish_once)
2407-
else
2408-
print(script_init_fish)
2412+
if prompt_hook then
2413+
if once then
2414+
print(script_init_fish_once)
2415+
else
2416+
print(script_init_fish)
2417+
end
24092418
end
24102419
print(script_complete_fish)
24112420
if opts.enhanced ~= nil then
@@ -2595,6 +2604,10 @@ if (!$env:_ZL_NO_PROMPT_COMMAND -and (!$global:_zlua_inited)) {
25952604
-- initialize cmd/powershell
25962605
-----------------------------------------------------------------------
25972606
function z_windows_init(opts)
2607+
local prompt_hook = (not os.environ("_ZL_NO_PROMPT_COMMAND", false))
2608+
if opts.clean ~= nil then
2609+
prompt_hook = false
2610+
end
25982611
if opts.powershell ~= nil then
25992612
print('$script:ZLUA_LUAEXE = "' .. os.interpreter() .. '"')
26002613
print('$script:ZLUA_SCRIPT = "' .. os.scriptname() .. '"')
@@ -2611,7 +2624,9 @@ function z_windows_init(opts)
26112624
if opts.nc ~= nil then
26122625
print('$env:_ZL_NO_CHECK = 1')
26132626
end
2614-
print(script_init_powershell)
2627+
if prompt_hook then
2628+
print(script_init_powershell)
2629+
end
26152630
else
26162631
print('@echo off')
26172632
print('setlocal EnableDelayedExpansion')

0 commit comments

Comments
 (0)