Skip to content

Instantly share code, notes, and snippets.

@keriszafir
Created February 13, 2017 15:08
Show Gist options
  • Save keriszafir/c1363a62654c2414f0fe90fe35dacf7d to your computer and use it in GitHub Desktop.
Save keriszafir/c1363a62654c2414f0fe90fe35dacf7d to your computer and use it in GitHub Desktop.
click edit wrapper for nano with autosave
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