Skip to content

Instantly share code, notes, and snippets.

@tong
Last active May 21, 2016 08:24
Show Gist options
  • Save tong/6893397 to your computer and use it in GitHub Desktop.
Save tong/6893397 to your computer and use it in GitHub Desktop.
bash/zsh completion for neko
#!bash
#
# bash/zsh completion support for neko/nekotools/nekoml/nekoc.
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
__neko(){
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -f -X "!*.n" -- "${cur}"))
}
complete -d -X '.[^./]*' -F __neko neko
__nekotools(){
local cur=${COMP_WORDS[COMP_CWORD]}
#local prev=${COMP_WORDS[COMP_CWORD-1]}
local opts="boot server"
# TODO 2nd level args
COMPREPLY=($(compgen -W "$opts" -- $cur))
}
complete -F __nekotools nekotools
__nekoml(){
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -f -X "!*.nml" -- "${cur}"))
}
complete -d -X '.[^./]*' -F __nekoml nekoml
__nekoc(){
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -f -X "!*.neko" -- "${cur}"))
}
complete -d -X '.[^./]*' -F __nekoc nekoc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment