Skip to content

Instantly share code, notes, and snippets.

@beucismis
Created August 4, 2022 11:49
Show Gist options
  • Select an option

  • Save beucismis/342702d6b57aacf95d0c9ccd3deb85b3 to your computer and use it in GitHub Desktop.

Select an option

Save beucismis/342702d6b57aacf95d0c9ccd3deb85b3 to your computer and use it in GitHub Desktop.
import os
import inquirer
EDITOR = os.environ["EDITOR"]
NOTES_PATH = os.environ["NOTES_PATH"]
questions = [
inquirer.List(
"filename",
message="Select file to edit",
choices=[
file
for file in os.listdir(NOTES_PATH)
if os.path.isfile(os.path.join(NOTES_PATH, file))
],
),
]
answers = inquirer.prompt(questions)
os.system(
"{} {}".format(
EDITOR,
os.path.join(NOTES_PATH, answers["filename"])
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment