Add default editor
This commit is contained in:
parent
e2c3a3e3e6
commit
7559af6495
11
diary.py
11
diary.py
@ -17,6 +17,8 @@ EDITOR_VARIABLES = [
|
|||||||
'EDITOR',
|
'EDITOR',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
DEFAULT_EDITOR = 'vi'
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
root_directory = get_root_directory()
|
root_directory = get_root_directory()
|
||||||
@ -74,12 +76,9 @@ def touch_file(full_path):
|
|||||||
|
|
||||||
|
|
||||||
def get_editor():
|
def get_editor():
|
||||||
for editor_variable in EDITOR_VARIABLES:
|
editors = [os.getenv(i) for i in EDITOR_VARIABLES]
|
||||||
editor = os.getenv(editor_variable)
|
available = [editor for editor in editors if editor]
|
||||||
if editor:
|
return next(iter(available), DEFAULT_EDITOR)
|
||||||
return editor
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def check_editor(editor):
|
def check_editor(editor):
|
||||||
|
Loading…
Reference in New Issue
Block a user