Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bash completion to shovel #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions completions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,22 @@ In the `completions/zsh` directory is a file to help with auto-completions in
2. Navigate to a directory where you've tasks in `shovel.py` or under
`shovel/`, and hit `TAB` twice. Or, type the first couple letters of a
command and hit `TAB` once. Boom.

Bash
----
In the `completions/bash` directory is a file to help with auto-completions in `bash`. Installation:

1. Install [bash-completion](https://github.com/scop/bash-completion) if you haven't already.
`brew install bash-completion@2`

2. Copy `completions/bash/shovel` to your local bash completions directory.

```
mkdir -p ~/.local/share/bash-completion/completions

cp completions/bash/shovel ~/.local/share/bash-completion/completions/shovel
```

3. Open a new terminal so the completions file will be sourced.

4. Navigate to a directory where tasks are in `shovel.py` or `shovel/` and hit `TAB` twice. Or type the first couple letters of a command and hit `TAB` once. Baam!
22 changes: 22 additions & 0 deletions completions/bash/shovel
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# shovel completion

_shovel()
{
local cur prev words cword
_init_completion || return

case $prev in
--help|--version|-!(-*)[h])
return
;;
esac

if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) )
elif [[ -f shovel.py || -d shovel ]]; then
COMPREPLY=( $( compgen -W '$(shovel tasks | cut -s -d"#" -f1) help tasks' -- "$cur") )
fi
} &&
complete -F _shovel shovel

# ex: filetype=sh