Skip to content

Commit

Permalink
chore: Add Alpine Bash devcontainer feature
Browse files Browse the repository at this point in the history
  • Loading branch information
cirolosapio committed Apr 23, 2024
1 parent 5ce749e commit 4d1a12b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 15 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Devcontainer Alpine Features

- [alpine-aws-cli](https://github.com/cirolosapio/devcontainers-features/pkgs/container/devcontainers-features%2Falpine-aws-cli)
- [alpine-bash](https://github.com/cirolosapio/devcontainers-features/pkgs/container/devcontainers-features%2Falpine-bash)
- [alpine-bat](https://github.com/cirolosapio/devcontainers-features/pkgs/container/devcontainers-features%2Falpine-bat)
- [alpine-bottom](https://github.com/cirolosapio/devcontainers-features/pkgs/container/devcontainers-features%2Falpine-bottom)
- [alpine-broot](https://github.com/cirolosapio/devcontainers-features/pkgs/container/devcontainers-features%2Falpine-broot)
Expand Down
7 changes: 7 additions & 0 deletions src/alpine-bash/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "alpine-bash",
"id": "alpine-bash",
"version": "0.0.1",
"description": "Installs bash on alpine",
"documentationURL": "https://github.com/cirolosapio/devcontainers-features/tree/main/src/alpine-bash"
}
11 changes: 11 additions & 0 deletions src/alpine-bash/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

set -e

echo "Activating feature 'alpine-bash'"

apk --no-cache add bash

sed -i "s|:/bin/ash|:/bin/bash|g" /etc/passwd

echo 'Done!'
10 changes: 2 additions & 8 deletions src/alpine-gh-copilot-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
{
"name": "alpine-gh-copilot-cli",
"id": "alpine-gh-copilot-cli",
"version": "0.0.12",
"version": "0.0.13",
"description": "Installs Github Copilot CLI on alpine",
"documentationURL": "https://github.com/cirolosapio/devcontainers-features/tree/main/src/alpine-gh-copilot-cli",
"installsAfter": [
"ghcr.io/cirolosapio/devcontainers-features/alpine-bash",
"ghcr.io/cirolosapio/devcontainers-features/alpine-ohmyzsh"
],
"options": {
"initAlias": {
"type": "boolean",
"default": true,
"description": "Setup alias convenience commands"
}
},
"customizations": {
"vscode": {
"extensions": [
Expand Down
12 changes: 9 additions & 3 deletions src/alpine-gh-copilot-cli/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ echo "Activating feature 'alpine-gh-copilot-cli'"
apk --no-cache add npm
npm i -g @githubnext/github-copilot-cli

if [[ $INITALIAS == "true" ]]; then
if command -v zsh &> /dev/null || command -v bash &> /dev/null; then
if command -v zsh &> /dev/null; then
RC_PROFILE=".zshrc"
else
RC_PROFILE=".bashrc"
fi

CURRENT_USER=$(getent passwd 1000 | cut -d: -f1)

if [ -z "$_CONTAINER_USER_HOME" ]; then
Expand All @@ -19,9 +25,9 @@ if [[ $INITALIAS == "true" ]]; then
fi

if [[ -z $CURRENT_USER ]]; then
echo 'eval "$(github-copilot-cli alias -- "$0")"' >> $_CONTAINER_USER_HOME/.zshrc
echo 'eval "$(github-copilot-cli alias -- "$0")"' >> $_CONTAINER_USER_HOME/$RC_PROFILE
else
CMD="echo 'eval \"\$(github-copilot-cli alias -- \"\$0\")\"' >> \$_CONTAINER_USER_HOME/.zshrc"
CMD="echo 'eval \"\$(github-copilot-cli alias -- \"\$0\")\"' >> \$_CONTAINER_USER_HOME/$RC_PROFILE"
su -c "$CMD" $CURRENT_USER
fi
fi
Expand Down
2 changes: 1 addition & 1 deletion src/alpine-nushell/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "alpine-nushell",
"id": "alpine-nushell",
"version": "0.0.9",
"version": "0.0.10",
"description": "Installs nushell on alpine",
"documentationURL": "https://github.com/cirolosapio/devcontainers-features/tree/main/src/alpine-nushell",
"installsAfter": [
Expand Down
14 changes: 11 additions & 3 deletions src/alpine-nushell/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

echo "Activating feature 'alpine-nushell'"

apk --no-cache add nushell --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing
apk --no-cache add nushell

if [ -z "$_CONTAINER_USER_HOME" ]; then
CURRENT_USER=$(getent passwd 1000 | cut -d: -f1)
Expand All @@ -17,12 +17,20 @@ if [ -z "$_CONTAINER_USER_HOME" ]; then
fi

mkdir -p $_CONTAINER_USER_HOME/.config/nushell/
wget -q https://raw.githubusercontent.com/nushell/nushell/main/crates/nu-utils/src/sample_config/default_config.nu -O $_CONTAINER_USER_HOME/.config/nushell/config.nu
wget -q https://raw.githubusercontent.com/nushell/nushell/main/crates/nu-utils/src/sample_config/default_env.nu -O $_CONTAINER_USER_HOME/.config/nushell/env.nu
# wget -q https://raw.githubusercontent.com/nushell/nushell/main/crates/nu-utils/src/sample_config/default_config.nu -O $_CONTAINER_USER_HOME/.config/nushell/config.nu
# wget -q https://raw.githubusercontent.com/nushell/nushell/main/crates/nu-utils/src/sample_config/default_env.nu -O $_CONTAINER_USER_HOME/.config/nushell/env.nu
wget -q https://raw.githubusercontent.com/nushell/nushell/2b5f1ee5b3e026e74f52983e47ce07f68a37fe34/crates/nu-utils/src/sample_config/default_config.nu -O $_CONTAINER_USER_HOME/.config/nushell/config.nu
wget -q https://raw.githubusercontent.com/nushell/nushell/2b5f1ee5b3e026e74f52983e47ce07f68a37fe34/crates/nu-utils/src/sample_config/default_env.nu -O $_CONTAINER_USER_HOME/.config/nushell/env.nu

if command -v starship &> /dev/null; then
echo $'\nmkdir ~/.cache/starship\nstarship init nu | save -f ~/.cache/starship/init.nu' >> $_CONTAINER_USER_HOME/.config/nushell/env.nu
echo $'\nuse ~/.cache/starship/init.nu' >> $_CONTAINER_USER_HOME/.config/nushell/config.nu
fi

if [ ! -z "$CURRENT_USER" ]; then
chown -R $CURRENT_USER $_CONTAINER_USER_HOME/.config/nushell
fi

sed -i "s|:/bin/ash|:/usr/bin/nu|g" /etc/passwd

echo 'Done!'

0 comments on commit 4d1a12b

Please sign in to comment.