Created
February 13, 2017 15:08
-
-
Save keriszafir/c1363a62654c2414f0fe90fe35dacf7d to your computer and use it in GitHub Desktop.
click edit wrapper for nano with autosave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import click | |
def edit(text=''): | |
"""Use nano as a preferred editor with autosave on exit | |
(easier on the user). | |
If nano is not available (e.g. on Windows), | |
use any editor found on the system""" | |
try: | |
edited_text = click.edit(text, editor='nano -t', require_save=False) | |
except click.ClickException: | |
edited_text = click.edit(text, require_save=False) | |
return edited_text | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment