From 05400a92ede5cd69546bd63bef07fbb14d9e523a Mon Sep 17 00:00:00 2001 From: Brutus Date: Thu, 24 Nov 2016 16:14:37 +0100 Subject: [PATCH] Added support for `~` and environment variables in `DEFAULT_CHEAT_DIR` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the `DEFAULT_CHEAT_DIR` environment variable contains the `~` — as shortcut for the users home directory — or environment variables like `$HOME`, the program bails. This change allows the usage of both. --- cheat/sheets.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cheat/sheets.py b/cheat/sheets.py index 4e09143..1a0b28e 100644 --- a/cheat/sheets.py +++ b/cheat/sheets.py @@ -7,7 +7,8 @@ def default_path(): """ Returns the default cheatsheet path """ # determine the default cheatsheet dir - default_sheets_dir = os.environ.get('DEFAULT_CHEAT_DIR') or os.path.join(os.path.expanduser('~'), '.cheat') + default_sheets_dir = os.environ.get('DEFAULT_CHEAT_DIR') or os.path.join('~', '.cheat') + default_sheets_dir = os.path.expanduser(os.path.expandvars(default_sheets_dir)) # create the DEFAULT_CHEAT_DIR if it does not exist if not os.path.isdir(default_sheets_dir):