Skip to content

Commit 777d821

Browse files
author
Richard Cunningham
committed
Add BASH history feature
1 parent 8a3dff2 commit 777d821

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "BASH terminal auto history configuration",
3+
"id": "BASH",
4+
"version": "1.0.0",
5+
"containerEnv": {
6+
"CONFIG_FOLDER": "/devcontainer_rc",
7+
"CONFIG_STAGING": "/devcontainer_staging"
8+
},
9+
"description": "Make default BASH terminal nicer.",
10+
// "options": {
11+
// "host_config_folder": {
12+
// "type": "string",
13+
// "default": "${localEnv:HOME}/.config/devcontainer_rc",
14+
// "description": "host folder for devcontainer shell configuration"
15+
// }
16+
// },
17+
"mounts": [
18+
{
19+
"source": "${localEnv:HOME}/.config/devcontainer_rc",
20+
"target": "/devcontainer_rc",
21+
"type": "bind"
22+
}
23+
],
24+
"onCreateCommand": "bash /devcontainer_staging/onCreateCommand.sh"
25+
}

src/terminal-history/install.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
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+
# Incremental history searching with up and down arrows (C-P and C-N for old
30+
# style navigation).
31+
"\e[A": history-search-backward
32+
"\e[B": history-search-forward
33+
34+
# Control left and right for word movement
35+
"\e[5C": forward-word
36+
"\e[5D": backward-word
37+
EOF
38+
39+
# -------------------------------------------------------------------------------
40+
cat > $CONFIG_STAGING/bashrc \
41+
<< EOF
42+
#!/bin/bash
43+
44+
# execute default opinionated settings - delete this line to remove defaults
45+
source $CONFIG_FOLDER/feature_settings_rc
46+
47+
# add your personal custom settings below
48+
EOF
49+
50+
# -------------------------------------------------------------------------------
51+
cat > $CONFIG_STAGING/feature_settings_rc \
52+
<< EOF
53+
#!/bin/bash
54+
55+
# default opinioned bash configuration
56+
57+
# set the prompt
58+
export PS1="\[\033[1;34m\]\W \[\033[0m\]# "
59+
60+
# enable enternal shared history
61+
export HISTCONTROL=ignoreboth:erasedups
62+
export HISTFILESIZE=-1
63+
export SAVEHIST=-1
64+
export HISTFILE=$CONFIG_FOLDER/.bash_eternal_history
65+
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
66+
EOF

0 commit comments

Comments
 (0)