Skip to content

Commit 107d79b

Browse files
committed
Add GIT_EDITOR
1 parent 18a60ce commit 107d79b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.devcontainer/features/bash-config/config/bash-config-rc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ __bash_prompt() {
3636
__bash_prompt
3737
export PROMPT_DIRTRIM=4
3838

39+
# Set the default git editor if not already set
40+
# from https://github.com/devcontainers/features/blob/f8e7e275b7ba2808e14a035afd753b83be68e2d9/src/common-utils/scripts/rc_snippet.sh
41+
if [ -z "$(git config --get core.editor)" ] && [ -z "${GIT_EDITOR}" ]; then
42+
if [ "${TERM_PROGRAM}" = "vscode" ]; then
43+
if [[ -n $(command -v code-insiders) && -z $(command -v code) ]]; then
44+
export GIT_EDITOR="code-insiders --wait"
45+
else
46+
export GIT_EDITOR="code --wait"
47+
fi
48+
fi
49+
fi
50+
3951
# enable bash completion for git
4052
if [[ -f /usr/share/bash-completion/completions/git ]]; then
4153
source /usr/share/bash-completion/completions/git

test/bash-config/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ source dev-container-features-test-lib
1111
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
1212
# check <LABEL> <cmd> [args...]
1313
check "execute command" bash -c "test $HISTFILE == $CONFIG_FOLDER/.bash_eternal_history"
14+
check "execute command" bash -c "test $GIT_EDITOR == 'code --wait'"
1415

1516
# Report results
1617
# If any of the checks above exited with a non-zero exit code, the test will fail.

0 commit comments

Comments
 (0)