mirror of
https://github.com/cheat/cheat.git
synced 2024-12-18 18:55:06 +01:00
cheat
now honors CHEAT_EDITOR
and VISUAL
environment variables in
addition to `EDITOR`.
This commit is contained in:
parent
eff042d50b
commit
6be87e2d42
@ -30,20 +30,21 @@ def die(message):
|
||||
|
||||
def editor():
|
||||
""" Determines the user's preferred editor """
|
||||
if 'EDITOR' not in os.environ:
|
||||
|
||||
# determine which editor to use
|
||||
editor = os.environ.get('CHEAT_EDITOR') \
|
||||
or os.environ.get('VISUAL') \
|
||||
or os.environ.get('EDITOR') \
|
||||
or False
|
||||
|
||||
# assert that the editor is set
|
||||
if editor == False:
|
||||
die(
|
||||
'In order to create/edit a cheatsheet you must set your EDITOR '
|
||||
'environment variable to your editor\'s path.'
|
||||
'You must set a CHEAT_EDITOR, VISUAL, or EDITOR environment '
|
||||
'variable in order to create/edit a cheatsheet.'
|
||||
)
|
||||
|
||||
elif os.environ['EDITOR'] == "":
|
||||
die(
|
||||
'Your EDITOR environment variable is set to an empty string. It must '
|
||||
'be set to your editor\'s path.'
|
||||
)
|
||||
|
||||
else:
|
||||
return os.environ['EDITOR']
|
||||
return editor
|
||||
|
||||
def warn(message):
|
||||
""" Prints a message to stderr """
|
||||
|
Loading…
Reference in New Issue
Block a user