Skip to content

Instantly share code, notes, and snippets.

@zereraz
Last active December 22, 2018 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zereraz/2d25cd2c6b9f9bb06ac41a8ba2b74b0f to your computer and use it in GitHub Desktop.
Save zereraz/2d25cd2c6b9f9bb06ac41a8ba2b74b0f to your computer and use it in GitHub Desktop.
todolist (todolist.site) autocomplete
#!/bin/bash
_projects() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=$(todolist list by p | cut -d ' ' -f 2 | grep -E "^[^\\[]+$" | sed -e 's/^/+/g')
if [[ ${cur} == +* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
complete -F _projects todolist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment