Permalink
Browse files

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.
  • Loading branch information...
1 parent 2df87f3 commit edb1745f32710bbf387d2ac85d2c19f7650ce118 @juergenhoetzel juergenhoetzel committed May 10, 2012
Showing with 2 additions and 4 deletions.
  1. +2 −4 bash_completion.bash
View
6 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)

0 comments on commit edb1745

Please sign in to comment.