Skip to content

Commit a4c589a

Browse files
author
skywind3000
committed
_ZL_FZF_FLAG can be used to override fzf parameters, default to "+s -e"
1 parent cb80215 commit a4c589a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ As you see, z.lua is the fastest one and requires less resource.
458458

459459
## History
460460

461+
- 1.5.5 (2019-02-20): `$_ZL_FZF_FLAG` can be used to override fzf flags, default to "+s -e".
461462
- 1.5.4 (2019-02-19): fixed: file/path existence detection fails on read-only fs (closed [#49](https://github.com/skywind3000/z.lua/issues/49) by [@contrun](https://github.com/contrun)).
462463
- 1.5.3 (2019-02-17): new `$_ZL_FZF_FLAG` for passing additional flags to fzf, add `-e` argument to fzf.
463464
- 1.5.2 (2019-02-16): be aware of all arguments in fzf completion.

z.lua

Lines changed: 9 additions & 6 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
55
-- Licensed under MIT license.
66
--
7-
-- Version 1.5.4, Last Modified: 2019/02/19 11:18
7+
-- Version 1.5.5, Last Modified: 2019/02/20 12:07
88
--
99
-- * 10x faster than fasd and autojump, 3x faster than z.sh
1010
-- * available for posix shells: bash, zsh, sh, ash, dash, busybox
@@ -1448,9 +1448,10 @@ function z_cd(patterns)
14481448
elseif Z_INTERACTIVE == 2 then
14491449
local fzf = os.environ('_ZL_FZF', 'fzf')
14501450
local tmpname = '/tmp/zlua.txt'
1451-
local cmd = '--nth 2.. --reverse --inline-info +s --tac -e'
1452-
cmd = ((fzf == '') and 'fzf' or fzf) .. ' ' .. cmd
1453-
cmd = cmd .. ' ' .. os.environ('_ZL_FZF_FLAG', '') .. ' '
1451+
local cmd = '--nth 2.. --reverse --inline-info --tac '
1452+
local flag = os.environ('_ZL_FZF_FLAG', '')
1453+
flag = (flag == '' or flag == nil) and '+s -e' or flag
1454+
cmd = ((fzf == '') and 'fzf' or fzf) .. ' ' .. cmd .. ' ' .. flag
14541455
if not windows then
14551456
tmpname = os.tmpname()
14561457
if not os.environ('_ZL_FZF_FULLSCR', false) then
@@ -1996,11 +1997,13 @@ function z_shell_init(opts)
19961997
end
19971998
print(script_complete_bash)
19981999
if opts.fzf ~= nil then
1999-
fzf_cmd = "fzf --nth 2 --reverse --inline-info +s --tac -e"
2000+
fzf_cmd = "fzf --nth 2 --reverse --inline-info --tac "
20002001
if not os.environ('_ZL_FZF_FULLSCR', false) then
20012002
fzf_cmd = fzf_cmd .. ' --height 35%'
20022003
end
2003-
fzf_cmd = fzf_cmd .. ' ' .. os.environ('_ZL_FZF_FLAG', '') .. ' '
2004+
local flag = os.environ('_ZL_FZF_FLAG', '')
2005+
flag = (flag == '' or flag == nil) and '+s -e' or flag
2006+
fzf_cmd = fzf_cmd .. ' ' .. flag .. ' '
20042007
print('zlua_fzf="' .. fzf_cmd .. '"')
20052008
print(script_fzf_complete_bash)
20062009
end

0 commit comments

Comments
 (0)