From 5c51f457a0fdf3c38cfa51bb84661f3fa7349f4f Mon Sep 17 00:00:00 2001 From: a-sk Date: Thu, 29 Aug 2013 18:41:00 +0400 Subject: [PATCH 1/3] Add -d/--cheat_directories option to list directories containing cheatsheets --- cheat | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cheat b/cheat index 2abc94a..ffca47d 100755 --- a/cheat +++ b/cheat @@ -121,7 +121,11 @@ def main(): # create/edit option option = sys.argv[1].lower() - if option in ['-e', '--edit', '-c', '--create']: + if option in ['-e', '--edit', '-c', '--create', '-d', '--cheat_directories']: + # list cheat directories and exit + if option in ['-d', '--cheat_directories']: + print(' '.join(cheat_directories())) + exit() # make sure EDITOR environment variable is set and that at least 3 arguments # are given if 'EDITOR' not in os.environ: From f20c0aba20151ec96554ee6dcd2092a9669fc4ba Mon Sep 17 00:00:00 2001 From: a-sk Date: Thu, 29 Aug 2013 19:05:46 +0400 Subject: [PATCH 2/3] Add zsh cheats completions --- _cheat | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 _cheat diff --git a/_cheat b/_cheat new file mode 100644 index 0000000..0ebec18 --- /dev/null +++ b/_cheat @@ -0,0 +1,12 @@ +#compdef cheat + +declare -a cheats cheats_in_this_dir + +for directory in $(cheat --cheat_directories); do + cheats_in_this_dir=($directory/*(N:r:t)) + [[ ${#cheats_in_this_dir} > 0 ]] && cheats+=($cheats_in_this_dir) +done + +_arguments "1:cheats:(${cheats})" + +return 1 From a781f6a8f7cbe1ef5e8b6e25e999325e2a40dda4 Mon Sep 17 00:00:00 2001 From: a-sk Date: Thu, 29 Aug 2013 19:06:05 +0400 Subject: [PATCH 3/3] Install zsh completions --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f4fd1c8..e05005a 100644 --- a/setup.py +++ b/setup.py @@ -12,5 +12,6 @@ setup(name='cheat', packages=['cheatsheets'], package_data={'cheatsheets': [f for f in os.listdir('cheatsheets') if '.' not in f]}, - scripts=['cheat'] + scripts=['cheat'], + data_files=[('/usr/share/zsh/site-functions', ['_cheat'])] )