Skip to content

Commit c651b00

Browse files
author
root
committed
first working example
1 parent a1365ba commit c651b00

File tree

3 files changed

+74
-7
lines changed

3 files changed

+74
-7
lines changed

.devcontainer/features/devcontainer-feature.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"id": "BASH",
44
"version": "1.0.0",
55
"containerEnv": {
6-
"CONFIG_FOLDER": "/devcontainer_rc"
6+
"CONFIG_FOLDER": "/devcontainer_rc",
7+
"CONFIG_STAGING": "/devcontainer_staging"
78
},
89
"description": "Make default BASH terminal nicer.",
910
// "options": {
@@ -20,7 +21,7 @@
2021
"type": "bind"
2122
}
2223
],
23-
"onCreateCommand": "bash .devcontainer/features/onCreateCommand.sh"
24+
"onCreateCommand": "bash /devcontainer_staging/onCreateCommand.sh"
2425
// wack below into /devcontainer_rc/.bashrc
2526
// delete this line if you do not want opinionated defaults
2627
// source .devcontainer_rc/.bash_generated.sh

.devcontainer/features/install.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,73 @@
11
#!/bin/bash
22

3+
mkdir -p $CONFIG_STAGING
4+
5+
# -------------------------------------------------------------------------------
6+
cat > $CONFIG_STAGING/onCreateCommand.sh \
7+
<< EOF
8+
#!/bin/bash
9+
10+
# copy in the opinionated default settings from the feature
11+
cp $CONFIG_STAGING/feature_settings_rc $CONFIG_FOLDER/feature_settings_rc
12+
13+
# copy in the user editable settings unless they already exist
14+
if [[ ! -f $CONFIG_FOLDER/bashrc ]] ; then
15+
cp $CONFIG_STAGING/bashrc $CONFIG_FOLDER
16+
cp $CONFIG_STAGING/inputrc $CONFIG_FOLDER
17+
fi
18+
19+
# hook in the config to the root account
20+
ln -s $CONFIG_FOLDER/inputrc /root/.inputrc
21+
echo "source $CONFIG_FOLDER/bashrc" >> /root/.bashrc
22+
EOF
23+
24+
# -------------------------------------------------------------------------------
25+
cat > $CONFIG_STAGING/inputrc \
26+
<< EOF
27+
# Readline configuration for bash shell.
28+
29+
# unbind ctrl P and ctrl Q
30+
"\C-p": nop
31+
# "\C-q": nop
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+
# On RHEL6 we get these bindings instead:
42+
"\e[1;5C": forward-word
43+
"\e[1;5D": backward-word
44+
EOF
45+
46+
# -------------------------------------------------------------------------------
47+
cat > $CONFIG_STAGING/bashrc \
48+
<< EOF
49+
#!/bin/bash
50+
51+
# execute default opinionated settings - delete this line to remove defaults
52+
source $CONFIG_FOLDER/feature_settings_rc
53+
54+
# add your personal custom settings below
55+
EOF
56+
57+
# -------------------------------------------------------------------------------
58+
cat > $CONFIG_STAGING/feature_settings_rc \
59+
<< EOF
60+
#!/bin/bash
61+
62+
# default opinioned bash configuration
63+
64+
# set the prompt
65+
export PS1='\W # '
66+
67+
# enable enternal shared history
68+
export HISTCONTROL=ignoreboth:erasedups
69+
export HISTFILESIZE=-1
70+
export SAVEHIST=-1
71+
export HISTFILE=$CONFIG_FOLDER/.bash_eternal_history
72+
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
73+
EOF

.devcontainer/features/onCreateCommand.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)