Skip to content

Commit

Permalink
Small fixes on rake.fish
Browse files Browse the repository at this point in the history
- Show the correct description of a task.
- Run the completion only if necessary.
  • Loading branch information
rflbras committed May 8, 2013
1 parent fbf691e commit b00e81b
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions completions/rake.fish
@@ -1,13 +1,16 @@
function __cache_or_get_rake_completion -d "Create rake completions"
mkdir -p "/tmp/rake_completion_cache_for_$USER"
set -l hashed_pwd (md5pwd)
set -l rake_cache_file "/tmp/rake_completion_cache_for_$USER/$hashed_pwd"

if not test -f "$rake_cache_file"
rake -T 2>&1 | sed -e "/^(/d" -e "s/^rake \([a-z:_0-9!\-]*\).*/\1/" > "$rake_cache_file"
end

cat "$rake_cache_file"
mkdir -p "/tmp/rake_completion_cache_for_$USER"
set -l hashed_pwd (md5pwd)
set -l rake_cache_file "/tmp/rake_completion_cache_for_$USER/$hashed_pwd"

if not test -f "$rake_cache_file"
rake -T 2>&1 | sed -e "s/^rake \([a-z:_0-9!\-]*\).*#\(.*\)/\1\t\2/" > "$rake_cache_file"
end
cat "$rake_cache_file"
end

function __run_rake_completion
test -f rakefile; or test -f Rakefile; or test -f rakefile.rb; or test -f Rakefile.rb
end

complete -x -c rake -a "(__cache_or_get_rake_completion)" --description 'Rake Task'
complete -x -c rake -a "(__cache_or_get_rake_completion)" -n __run_rake_completion

0 comments on commit b00e81b

Please sign in to comment.