From 5fbe9bf611562dcd144e474cbe8a56eccd808428 Mon Sep 17 00:00:00 2001 From: Richard Cunningham Date: Fri, 22 Nov 2024 09:17:47 +0000 Subject: [PATCH] Create colorthree --- .../features/color/devcontainer-feature.json | 4 +- .../colorthree/devcontainer-feature.json | 18 +++++ .devcontainer/features/colorthree/install.sh | 70 +++++++++++++++++++ 3 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/features/colorthree/devcontainer-feature.json create mode 100644 .devcontainer/features/colorthree/install.sh diff --git a/.devcontainer/features/color/devcontainer-feature.json b/.devcontainer/features/color/devcontainer-feature.json index 224cf23..82b83c9 100644 --- a/.devcontainer/features/color/devcontainer-feature.json +++ b/.devcontainer/features/color/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "My Favorite Color", - "id": "a", - "version": "1.0.3", + "id": "color", + "version": "1.0.4", "description": "A feature to remind you of your favorite color", "options": { "favorite": { diff --git a/.devcontainer/features/colorthree/devcontainer-feature.json b/.devcontainer/features/colorthree/devcontainer-feature.json new file mode 100644 index 0000000..c455a07 --- /dev/null +++ b/.devcontainer/features/colorthree/devcontainer-feature.json @@ -0,0 +1,18 @@ +{ + "name": "My Final Favorite Color", + "id": "colorthree", + "version": "1.0.0", + "description": "Another feature to remind you of your favorite color", + "containerEnv": { + "CONFIG_FOLDER": "/devcontainer_rc", + "CONFIG_STAGING": "/devcontainer_staging" + }, + "mounts": [ + { + "source": "${localEnv:HOME}/.config/devcontainer_rc", + "target": "/devcontainer_rc", + "type": "bind" + } + ], + "onCreateCommand": "bash /devcontainer_staging/onCreateCommand.sh" +} \ No newline at end of file diff --git a/.devcontainer/features/colorthree/install.sh b/.devcontainer/features/colorthree/install.sh new file mode 100644 index 0000000..01a6cb5 --- /dev/null +++ b/.devcontainer/features/colorthree/install.sh @@ -0,0 +1,70 @@ +#!/bin/bash +set -e + +echo "Activating feature 'terminal-history'" +echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" + +mkdir -p $CONFIG_STAGING + +# ------------------------------------------------------------------------------- +cat > $CONFIG_STAGING/onCreateCommand.sh \ +<< EOF +#!/bin/bash + +# copy in the opinionated default settings from the feature +cp $CONFIG_STAGING/feature_settings_rc $CONFIG_FOLDER/feature_settings_rc + +# copy in the user editable settings unless they already exist +if [[ ! -f $CONFIG_FOLDER/bashrc ]] ; then + cp $CONFIG_STAGING/bashrc $CONFIG_FOLDER + cp $CONFIG_STAGING/inputrc $CONFIG_FOLDER +fi + +# hook in the config to the root account +ln -s $CONFIG_FOLDER/inputrc /root/.inputrc +echo "source $CONFIG_FOLDER/bashrc" >> /root/.bashrc +EOF + +# ------------------------------------------------------------------------------- +cat > $CONFIG_STAGING/inputrc \ +<< EOF +# Readline configuration for bash shell. + +# Incremental history searching with up and down arrows (C-P and C-N for old +# style navigation). +"\e[A": history-search-backward +"\e[B": history-search-forward + +# Control left and right for word movement +"\e[5C": forward-word +"\e[5D": backward-word +EOF + +# ------------------------------------------------------------------------------- +cat > $CONFIG_STAGING/bashrc \ +<< EOF +#!/bin/bash + +# execute default opinionated settings - delete this line to remove defaults +source $CONFIG_FOLDER/feature_settings_rc + +# add your personal custom settings below +EOF + +# ------------------------------------------------------------------------------- +cat > $CONFIG_STAGING/feature_settings_rc \ +<< EOF +#!/bin/bash + +# default opinioned bash configuration + +# set the prompt +export PS1="\[\033[1;34m\]\W \[\033[0m\]# " + +# enable enternal shared history +export HISTCONTROL=ignoreboth:erasedups +export HISTFILESIZE=-1 +export SAVEHIST=-1 +export HISTFILE=$CONFIG_FOLDER/.bash_eternal_history +PROMPT_COMMAND="history -a; $PROMPT_COMMAND" +EOF