From edb1745f32710bbf387d2ac85d2c19f7650ce118 Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Thu, 10 May 2012 17:27:13 +0200 Subject: [PATCH] Improve namespace completion performance Dont execute a grep command for each single Clojure file: Use exec '+' variant to search all Clojure files via sed only once. --- bash_completion.bash | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bash_completion.bash b/bash_completion.bash index d502a1a6e..26a5e5ea3 100644 --- a/bash_completion.bash +++ b/bash_completion.bash @@ -20,14 +20,12 @@ _lein_completion() { ;; test | retest ) # list project's test namespaces: - local namespaces=$(find test/ -type f -name "*.clj" -exec grep -E \ - '^\(ns[[:space:]]+\w+' '{}' ';' | sed -n 's/(ns[ ]*//p') + local namespaces=$(find test/ -type f -name "*.clj" -exec sed -n 's/^(ns[ ]*//p' '{}' '+') COMPREPLY=( $(compgen -W "${namespaces}" -- ${cur}) ) ;; run | compile) # list project's src namespaces: - local namespaces=$(find src/ -type f -name "*.clj" -exec grep -E \ - '^\(ns[[:space:]]+\w+' '{}' ';' | sed -n 's/(ns[ ]*//p') + local namespaces=$(find src/ -type f -name "*.clj" -exec sed -n 's/^(ns[ ]*//p' '{}' '+') COMPREPLY=( $(compgen -W "${namespaces}" -- ${cur}) ) ;; lein)