Skip to content

Commit 5fbe9bf

Browse files
author
Richard Cunningham
committed
Create colorthree
1 parent 3ad3fe6 commit 5fbe9bf

File tree

3 files changed

+90
-2
lines changed

3 files changed

+90
-2
lines changed

.devcontainer/features/color/devcontainer-feature.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "My Favorite Color",
3-
"id": "a",
4-
"version": "1.0.3",
3+
"id": "color",
4+
"version": "1.0.4",
55
"description": "A feature to remind you of your favorite color",
66
"options": {
77
"favorite": {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "My Final Favorite Color",
3+
"id": "colorthree",
4+
"version": "1.0.0",
5+
"description": "Another feature to remind you of your favorite color",
6+
"containerEnv": {
7+
"CONFIG_FOLDER": "/devcontainer_rc",
8+
"CONFIG_STAGING": "/devcontainer_staging"
9+
},
10+
"mounts": [
11+
{
12+
"source": "${localEnv:HOME}/.config/devcontainer_rc",
13+
"target": "/devcontainer_rc",
14+
"type": "bind"
15+
}
16+
],
17+
"onCreateCommand": "bash /devcontainer_staging/onCreateCommand.sh"
18+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Activating feature 'terminal-history'"
5+
echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}"
6+
7+
mkdir -p $CONFIG_STAGING
8+
9+
# -------------------------------------------------------------------------------
10+
cat > $CONFIG_STAGING/onCreateCommand.sh \
11+
<< EOF
12+
#!/bin/bash
13+
14+
# copy in the opinionated default settings from the feature
15+
cp $CONFIG_STAGING/feature_settings_rc $CONFIG_FOLDER/feature_settings_rc
16+
17+
# copy in the user editable settings unless they already exist
18+
if [[ ! -f $CONFIG_FOLDER/bashrc ]] ; then
19+
cp $CONFIG_STAGING/bashrc $CONFIG_FOLDER
20+
cp $CONFIG_STAGING/inputrc $CONFIG_FOLDER
21+
fi
22+
23+
# hook in the config to the root account
24+
ln -s $CONFIG_FOLDER/inputrc /root/.inputrc
25+
echo "source $CONFIG_FOLDER/bashrc" >> /root/.bashrc
26+
EOF
27+
28+
# -------------------------------------------------------------------------------
29+
cat > $CONFIG_STAGING/inputrc \
30+
<< EOF
31+
# Readline configuration for bash shell.
32+
33+
# Incremental history searching with up and down arrows (C-P and C-N for old
34+
# style navigation).
35+
"\e[A": history-search-backward
36+
"\e[B": history-search-forward
37+
38+
# Control left and right for word movement
39+
"\e[5C": forward-word
40+
"\e[5D": backward-word
41+
EOF
42+
43+
# -------------------------------------------------------------------------------
44+
cat > $CONFIG_STAGING/bashrc \
45+
<< EOF
46+
#!/bin/bash
47+
48+
# execute default opinionated settings - delete this line to remove defaults
49+
source $CONFIG_FOLDER/feature_settings_rc
50+
51+
# add your personal custom settings below
52+
EOF
53+
54+
# -------------------------------------------------------------------------------
55+
cat > $CONFIG_STAGING/feature_settings_rc \
56+
<< EOF
57+
#!/bin/bash
58+
59+
# default opinioned bash configuration
60+
61+
# set the prompt
62+
export PS1="\[\033[1;34m\]\W \[\033[0m\]# "
63+
64+
# enable enternal shared history
65+
export HISTCONTROL=ignoreboth:erasedups
66+
export HISTFILESIZE=-1
67+
export SAVEHIST=-1
68+
export HISTFILE=$CONFIG_FOLDER/.bash_eternal_history
69+
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
70+
EOF

0 commit comments

Comments
 (0)