diff --git a/bin/cheat b/bin/cheat index a14e3a9..c009906 100755 --- a/bin/cheat +++ b/bin/cheat @@ -8,6 +8,7 @@ Usage: cheat cheat -e cheat -s + cheat -S cheat -l cheat -d cheat -v @@ -17,6 +18,7 @@ Options: -e --edit Edit cheatsheet -l --list List cheatsheets -s --search Search cheatsheets for + -S --search-ignore-case Search cheatsheets for , ignoring case -v --version Print the version number Examples: @@ -58,7 +60,11 @@ if __name__ == '__main__': # search among the cheatsheets elif options['--search']: - print(colorize(sheets.search(options['']))) + print(colorize(sheets.search(options[''], True))) + + # search among the cheatsheets, ignoring case + elif options['--search-ignore-case']: + print(colorize(sheets.search(options[''], False))) # print the cheatsheet else: diff --git a/cheat/sheets.py b/cheat/sheets.py index 1a0b28e..07c509e 100644 --- a/cheat/sheets.py +++ b/cheat/sheets.py @@ -76,15 +76,19 @@ def list(): return sheet_list -def search(term): +def search(term, match_case): """ Searches all cheatsheets for the specified term """ result = '' for cheatsheet in sorted(get().items()): match = '' for line in open(cheatsheet[1]): - if term in line: - match += ' ' + line + if match_case: + if term in line: + match += ' ' + line + else: + if term.lower() in line.lower(): + match += ' ' + line if match != '': result += cheatsheet[0] + ":\n" + match + "\n" diff --git a/man1/cheat.1.gz b/man1/cheat.1.gz index 65bc32f..acc6c18 100644 Binary files a/man1/cheat.1.gz and b/man1/cheat.1.gz differ