From 76a053f42df0d38eed320aa8e54660aa6ea90d09 Mon Sep 17 00:00:00 2001 From: beels <1375300+beels@users.noreply.github.com> Date: Sat, 7 Oct 2023 18:44:04 -0400 Subject: [PATCH] Trim away un-needed select menu content (#1712) * Do not scan through .git directories while looking for scripts (optimization of `find` call only). * Filter out unwanted lua scripts before returning from shell. Co-authored-by: Alexander Beels --- lua/core/menu/select.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lua/core/menu/select.lua b/lua/core/menu/select.lua index 6cb7ccf19..757aee06d 100644 --- a/lua/core/menu/select.lua +++ b/lua/core/menu/select.lua @@ -28,11 +28,7 @@ local function sort_select_tree(results) local t = {} for filename in results:gmatch("[^\r\n]+") do - if string.match(filename,"/data/")==nil and - string.match(filename,"/lib/")==nil and - string.match(filename,"/crow/")==nil then - table.insert(t,filename) - end + table.insert(t,'/home/we/dust/code/' .. filename) end for _,file in pairs(t) do @@ -62,7 +58,11 @@ m.init = function() tabutil.save(m.favorites, paths.favorites) end -- weird command, but it is fast, recursive, skips hidden dirs, and sorts - norns.system_cmd('find ~/dust/code/ -name "*.lua" -printf "%P\n"| sort', sort_select_tree) + norns.system_cmd('find ~/dust/code/ -mindepth 2 ' .. + '-name .git -prune -o -type f -name "*.lua" -printf "%P\n" | ' .. + 'grep -Ev "/(lib|data|crow)/" | ' .. + 'sort', + sort_select_tree) end m.deinit = norns.none