Skip to content

Commit

Permalink
Enable git autocomplete in the devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjstevens committed Jan 19, 2024
1 parent a364dcf commit 1f15bd9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
"features": {
"./git-autocomplete": "1.0.0",
},
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
Expand Down
6 changes: 6 additions & 0 deletions .devcontainer/git-autocomplete/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Git Autocomplete",
"id": "git-autocomplete",
"version": "1.0.0",
"description": "Enable git autocomplete in the shell",
}
13 changes: 13 additions & 0 deletions .devcontainer/git-autocomplete/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
UPDATE_RC="${UPDATE_RC:-"true"}"
AUTOCOMPLETE_SOURCE="source /usr/share/bash-completion/completions/git"

if [ "${UPDATE_RC}" = "true" ]; then
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
if [[ "$(cat /etc/bash.bashrc)" != *"${AUTOCOMPLETE_SOURCE}"* ]]; then
echo -e "${AUTOCOMPLETE_SOURCE}" >> /etc/bash.bashrc
fi
if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"${AUTOCOMPLETE_SOURCE}"* ]]; then
echo -e "${AUTOCOMPLETE_SOURCE}" >> /etc/zsh/zshrc
fi
fi

0 comments on commit 1f15bd9

Please sign in to comment.