From 4c3a2cd1112f958a00c402cb9cb8024044d29c68 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Tue, 11 Feb 2025 14:04:46 +0100 Subject: [PATCH] Change note creation script uses EDITOR environment variable Changes the script for creating change notes to read the EDITOR environment variable, and use the editor specified therein. This makes the script more convenient when used from a terminal. The VSCode task is updated to the set EDITOR to `code -r` which preserves the current behavior. --- .vscode/tasks.json | 10 ++++++++++ misc/scripts/create-change-note.py | 8 +++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 5e4b9397d26..5786439f38f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -50,6 +50,11 @@ "${input:name}", "${input:categoryQuery}" ], + "options": { + "env": { + "EDITOR": "code -r", + } + }, "presentation": { "reveal": "never", "close": true @@ -67,6 +72,11 @@ "${input:name}", "${input:categoryLibrary}" ], + "options": { + "env": { + "EDITOR": "code -r" + } + }, "presentation": { "reveal": "never", "close": true diff --git a/misc/scripts/create-change-note.py b/misc/scripts/create-change-note.py index 548fa4e87fb..eb7eb95e7b8 100755 --- a/misc/scripts/create-change-note.py +++ b/misc/scripts/create-change-note.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 -# Creates a change note and opens it in VSCode for editing. +# Creates a change note and opens it in $EDITOR (or VSCode if the environment +# variable is not set) for editing. # Expects to receive the following arguments: # - What language the change note is for @@ -51,5 +52,6 @@ category: {change_category} with open(change_note_file, "w") as f: f.write(change_note) -# Open the change note file in VSCode, reusing the existing window if possible -os.system(f"code -r {change_note_file}") +editor = os.environ.get('EDITOR', 'code') + +os.system(f"{editor} {change_note_file}")