Skip to content

Commit

Permalink
Project names completion function.
Browse files Browse the repository at this point in the history
  • Loading branch information
aartamonau committed Aug 7, 2011
1 parent 0343bc8 commit dd83723
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions repo.bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,16 @@ _find_repo() {
dir=$(cd "${dir}/.." && pwd)
done

return ${found}
if [ ${found} -eq 0 ]
then
echo "${dir}"
fi
}

_is_repo_dir() {
local repo_root=$(_find_repo)

[ -n "${repo_root}" ]
}

_gen_comps() {
Expand Down Expand Up @@ -93,6 +102,16 @@ _dir_completion() {
_filedir -d
}

_project_completion() {
local repo_root=$(_find_repo)

if [ -n "${repo_root}" -a -f "${repo_root}/.repo/project.list" ]
then
local projects=$(cat "${repo_root}/.repo/project.list")
_gen_comps "${projects}"
fi
}

_is_option() {
local opt="$1"

Expand Down Expand Up @@ -436,7 +455,7 @@ _repo() {
local curr="${COMP_WORDS[COMP_CWORD]}"
local cmds

if _find_repo
if _is_repo_dir
then
cmds=("abandon" "branch" "branches" "checkout" "cherry-pick" "diff"
"download" "forall" "grep" "help" "init" "list" "prune" "rebase"
Expand Down

0 comments on commit dd83723

Please sign in to comment.