From 845490d3f3426176cae6d7e5420f48577d12d282 Mon Sep 17 00:00:00 2001 From: Tom Cobb Date: Fri, 20 Dec 2024 14:09:10 +0000 Subject: [PATCH] Add GIT_EDITOR --- .../features/bash-config/config/bash-config-rc | 12 ++++++++++++ test/bash-config/test.sh | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.devcontainer/features/bash-config/config/bash-config-rc b/.devcontainer/features/bash-config/config/bash-config-rc index 5e3f78a..ce5b446 100644 --- a/.devcontainer/features/bash-config/config/bash-config-rc +++ b/.devcontainer/features/bash-config/config/bash-config-rc @@ -36,6 +36,18 @@ __bash_prompt() { __bash_prompt export PROMPT_DIRTRIM=4 +# Set the default git editor if not already set +# from https://github.com/devcontainers/features/blob/f8e7e275b7ba2808e14a035afd753b83be68e2d9/src/common-utils/scripts/rc_snippet.sh +if [ -z "$(git config --get core.editor)" ] && [ -z "${GIT_EDITOR}" ]; then + if [ "${TERM_PROGRAM}" = "vscode" ]; then + if [[ -n $(command -v code-insiders) && -z $(command -v code) ]]; then + export GIT_EDITOR="code-insiders --wait" + else + export GIT_EDITOR="code --wait" + fi + fi +fi + # enable bash completion for git if [[ -f /usr/share/bash-completion/completions/git ]]; then source /usr/share/bash-completion/completions/git diff --git a/test/bash-config/test.sh b/test/bash-config/test.sh index 2886eb3..6c413ca 100644 --- a/test/bash-config/test.sh +++ b/test/bash-config/test.sh @@ -10,7 +10,8 @@ source dev-container-features-test-lib # Feature-specific tests # The 'check' command comes from the dev-container-features-test-lib. Syntax is... # check