From 8b8d06f0e19c61322fce32c6ef2a603ac4680549 Mon Sep 17 00:00:00 2001 From: roemer_j Date: Thu, 12 Sep 2013 03:25:10 +0200 Subject: [PATCH] Added autocomplete for bash --- cheat-completion.bash | 14 ++++++++++++++ setup.py | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 cheat-completion.bash diff --git a/cheat-completion.bash b/cheat-completion.bash new file mode 100644 index 0000000..eef3ac2 --- /dev/null +++ b/cheat-completion.bash @@ -0,0 +1,14 @@ +# +# Autocomplete for cheat.py +# Copyright (c) 2013, Jean-Philippee "Orax" Roemer +# + +function _cheat_autocomplete { + sheets=$(cheat | tail -n +17 | cut -d' ' -f1) + COMPREPLY=() + if [ $COMP_CWORD = 1 ]; then + COMPREPLY=(`compgen -W "$sheets" -- $2`) + fi +} + +complete -F _cheat_autocomplete cheat diff --git a/setup.py b/setup.py index c115c4c..5d7ffe5 100644 --- a/setup.py +++ b/setup.py @@ -17,5 +17,6 @@ setup(name='cheat', package_data={'cheatsheets': [f for f in os.listdir('cheatsheets') if '.' not in f]}, scripts=['cheat'], - data_files=[('/usr/share/zsh/site-functions', ['_cheat'])] + data_files=[('/usr/share/zsh/site-functions', ['_cheat']), + ('/etc/bash_completion.d', ['cheat-completion.bash'])] )