Skip to content

Commit

Permalink
rewriting code dir completion as project completion
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanb committed Jun 21, 2008
1 parent 051f724 commit 12ef1e3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
4 changes: 0 additions & 4 deletions bash/completion_scripts/code_dir_completion

This file was deleted.

24 changes: 24 additions & 0 deletions bash/completion_scripts/project_completion
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env ruby

class ProjectCompletion
def initialize(command)
@command = command
end

def matches
projects.select do |task|
task[0, typed.length] == typed
end
end

def typed
@command[/\s(.+?)$/, 1] || ''
end

def projects
`ls ~/code/`.split
end
end

puts ProjectCompletion.new(ENV["COMP_LINE"]).matches
exit 0
2 changes: 1 addition & 1 deletion bash/completions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source ~/.bash/completion_scripts/git_completion
complete -C ~/.bash/completion_scripts/rake_completion -o default rake
complete -C ~/.bash/completion_scripts/code_dir_completion -o default c
complete -C ~/.bash/completion_scripts/project_completion -o default c

0 comments on commit 12ef1e3

Please sign in to comment.