Skip to content

Commit

Permalink
Make tab expansion less picky about when it will expand; clean up reg…
Browse files Browse the repository at this point in the history
…ex with non-capturing groups
  • Loading branch information
dahlbyk committed Jul 26, 2010
1 parent 7ae4298 commit 894c0c4
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions GitTabExpansion.ps1
Expand Up @@ -97,20 +97,14 @@ function GitTabExpansion($lastBlock) {
}

# Handles git stash (show|apply|drop|pop|branch) <stash>
'git stash (show|apply|drop|pop|branch) (\S*)$' {
gitStashes $matches[2]
'git stash (?:show|apply|drop|pop|branch).* (\S*)$' {
gitStashes $matches[1]
}

# Handles git branch -d|-D|-m|-M <branch name>
'git branch -(d|D|m|M) (\S*)$' {
gitLocalBranches $matches[2]
}

# Handles git checkout <branch name>
# Handles git merge <branch name>
# handles git rebase <branch name>
'git (checkout|merge|rebase) (\S*)$' {
gitLocalBranches $matches[2]
# Handles git branch <branch name> <start-point>
'git branch.* (\S*)$' {
gitLocalBranches $matches[1]
}

# Handles git <cmd> (commands & aliases)
Expand All @@ -125,29 +119,42 @@ function GitTabExpansion($lastBlock) {

# Handles git push remote <branch>
# Handles git pull remote <branch>
'git (push|pull) (\S+) (\S*)$' {
gitLocalBranches $matches[3]
'git (?:push|pull).* (?:\S+) (\S*)$' {
gitLocalBranches $matches[1]
}

# Handles git pull <remote>
# Handles git push <remote>
'git (push|pull) (\S*)$' {
gitRemotes $matches[2]
'git (?:push|pull).* (\S*)$' {
gitRemotes $matches[1]
}

# Handles git reset HEAD <path>
'git reset HEAD (\S*)$' {
# Handles git reset HEAD -- <path>
'git reset.* HEAD(?:\s+--)? (\S*)$' {
gitIndex $matches[1]
}

# Handles git add <path>
'git add (\S*)$' {
'git add.* (\S*)$' {
gitFiles $matches[1]
}

# Handles git checkout -- <path>
'git checkout -- (\S*)$' {
'git checkout.* -- (\S*)$' {
gitFiles $matches[1]
}

# Handles git rm <path>
'git rm.* (\S*)$' {
gitIndex $matches[1]
}

# Handles git checkout <branch name>
# Handles git merge <branch name>
# handles git rebase <branch name>
'git (?:checkout|merge|rebase).* (\S*)$' {
gitLocalBranches $matches[1]
}
}
}

0 comments on commit 894c0c4

Please sign in to comment.