Skip to content

Commit

Permalink
Improve namespace completion performance
Browse files Browse the repository at this point in the history
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
juergenhoetzel committed May 10, 2012
1 parent 2df87f3 commit edb1745
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions bash_completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit edb1745

Please sign in to comment.