From 2a69ffa374c1429e10f91aa80ceda06d6accbec4 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 17 Apr 2017 13:28:40 +0200 Subject: [PATCH] awful.completion: zsh: fix command completion from PWD Fixes https://github.com/awesomeWM/awesome/issues/1734. --- lib/awful/completion.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/awful/completion.lua b/lib/awful/completion.lua index 630929d1..c5e640f8 100644 --- a/lib/awful/completion.lua +++ b/lib/awful/completion.lua @@ -103,15 +103,17 @@ function completion.shell(command, cur_pos, ncomp, shell) -- NOTE: ${~:-"..."} turns on GLOB_SUBST, useful for expansion of -- "~/" ($HOME). ${:-"foo"} is the string "foo" as var. shell_cmd = "/usr/bin/env zsh -c 'local -a res; res=( ${~:-" - .. string.format('%q', words[cword_index]) .. "}* ); " + .. string.format('%q', words[cword_index]) .. "}*(N) ); " .. "print -ln -- ${res[@]}'" else - -- check commands, aliases, builtins, functions and reswords - shell_cmd = "/usr/bin/env zsh -c 'local -a res; ".. + -- Check commands, aliases, builtins, functions and reswords. + -- Adds executables and non-empty dirs from $PWD (pwd_exe). + shell_cmd = "/usr/bin/env zsh -c 'local -a res pwd_exe; ".. + "pwd_exe=(*(N*:t) *(NF:t)); ".. "res=( ".. "\"${(k)commands[@]}\" \"${(k)aliases[@]}\" \"${(k)builtins[@]}\" \"${(k)functions[@]}\" ".. "\"${(k)reswords[@]}\" ".. - "${PWD}/*(:t)".. + "./${^${pwd_exe}} ".. "); ".. "print -ln -- ${(M)res[@]:#" .. string.format('%q', words[cword_index]) .. "*}'" end