mirror of https://github.com/cheat/cheat.git
Merge branch 'zsh_completions' of https://github.com/a-sk/cheat into a-sk-zsh_completions
* 'zsh_completions' of https://github.com/a-sk/cheat: Install zsh completions Add zsh cheats completions Add -d/--cheat_directories option to list directories containing cheatsheets
This commit is contained in:
commit
91d01d9b96
|
@ -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
|
6
cheat
6
cheat
|
@ -122,7 +122,11 @@ def main():
|
||||||
|
|
||||||
# create/edit option
|
# create/edit option
|
||||||
option = sys.argv[1].lower()
|
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
|
# make sure EDITOR environment variable is set and that at least 3 arguments
|
||||||
# are given
|
# are given
|
||||||
if 'EDITOR' not in os.environ:
|
if 'EDITOR' not in os.environ:
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -16,5 +16,6 @@ setup(name='cheat',
|
||||||
packages=['cheatsheets'],
|
packages=['cheatsheets'],
|
||||||
package_data={'cheatsheets': [f for f in os.listdir('cheatsheets')
|
package_data={'cheatsheets': [f for f in os.listdir('cheatsheets')
|
||||||
if '.' not in f]},
|
if '.' not in f]},
|
||||||
scripts=['cheat']
|
scripts=['cheat'],
|
||||||
|
data_files=[('/usr/share/zsh/site-functions', ['_cheat'])]
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue