From e662862b7bc8d1f7574ad9011ff2404863d53b76 Mon Sep 17 00:00:00 2001 From: a-sk Date: Thu, 29 Aug 2013 18:20:23 +0400 Subject: [PATCH 1/3] Introduce DEFAULT_CHEAT_DIR environment variable Now ~/.cheat can be overridden --- cheat | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cheat b/cheat index 2abc94a..ce8592c 100755 --- a/cheat +++ b/cheat @@ -3,7 +3,8 @@ import os import sys import subprocess -DEFAULT_CHEAT_DIR = os.path.join(os.path.expanduser('~'), '.cheat') +DEFAULT_CHEAT_DIR = os.environ.get('DEFAULT_CHEAT_DIR') or \ + os.path.join(os.path.expanduser('~'), '.cheat') USE_PYGMENTS = False # NOTE remove this check if it is confirmed to work on windows @@ -140,6 +141,7 @@ def main(): elif option in ['-c', '--create']: create_cheatsheet(' '.join(sys.argv[2:]), cheatsheets) + # print the cheatsheet if it exists if keyphrase in cheatsheets: filename = os.path.join(cheatsheets[keyphrase], keyphrase) From 23de32ce509c2f6a3e67862e76ef814881974ba4 Mon Sep 17 00:00:00 2001 From: a-sk Date: Thu, 29 Aug 2013 19:16:01 +0400 Subject: [PATCH 2/3] Remove odd new line --- cheat | 1 - 1 file changed, 1 deletion(-) diff --git a/cheat b/cheat index ce8592c..22007a8 100755 --- a/cheat +++ b/cheat @@ -141,7 +141,6 @@ def main(): elif option in ['-c', '--create']: create_cheatsheet(' '.join(sys.argv[2:]), cheatsheets) - # print the cheatsheet if it exists if keyphrase in cheatsheets: filename = os.path.join(cheatsheets[keyphrase], keyphrase) From 702f043ff41401355a4192f8731f21db0fed4913 Mon Sep 17 00:00:00 2001 From: a-sk Date: Thu, 29 Aug 2013 19:19:19 +0400 Subject: [PATCH 3/3] Add note about DEFAULT_CHEAT_DIR to the README file --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 64a95ae..94636e1 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,14 @@ Advanced Features Setting a CHEATPATH ---------------------- + +By default cheatsheets are stored in the `~/.cheat/` directory, you can +override it by setting `DEFAULT_CHEAT_DIR` environment variable. + +```bash +export DEFAULT_CHEAT_DIR=/path/to/my/cheats +``` + By default, all cheatsheets are installed to `~/.cheat/`, but you can instruct `cheat` to look for cheatsheets in other directories by exporting a `CHEATPATH` environment variable: