Skip to content

Commit bb04e88

Browse files
authored
Adds shell history volume (#29)
1 parent 5dd91dd commit bb04e88

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

.devcontainer/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,27 @@ RUN set -eux; \
4343
RUN git clone https://github.com/jaggedmountain/k-alias.git /tmp/k-alias && \
4444
cp /tmp/k-alias/[h,k]* /usr/local/bin
4545

46+
# Configure ZSH History
47+
RUN mkdir -p "/home/vscode/.history" && touch "/home/vscode/.history/zsh_history" && \
48+
chown -R vscode:vscode /home/vscode/.history && \
49+
cat >> /home/vscode/.zshrc <<'EOF'
50+
# Persistent zsh history for devcontainer
51+
# Use a dedicated history directory (backed by a Docker volume)
52+
mkdir -p "/home/vscode/.history"
53+
export HISTFILE="/home/vscode/.history/zsh_history"
54+
export HISTSIZE=50000 # in-memory commands
55+
export SAVEHIST=100000 # on-disk commands
56+
# History behavior options
57+
setopt APPEND_HISTORY # append to history file, don't overwrite
58+
setopt INC_APPEND_HISTORY # write each command as it's entered
59+
setopt SHARE_HISTORY # share history across sessions
60+
setopt HIST_IGNORE_DUPS # ignore immediate duplicates
61+
setopt HIST_IGNORE_ALL_DUPS # drop older duplicates
62+
setopt HIST_IGNORE_SPACE # ignore commands starting with a space
63+
setopt HIST_REDUCE_BLANKS # trim extra spaces
64+
setopt HIST_VERIFY # don't immediately execute recalled commands
65+
# DEVCONTAINER ZSH HISTORY END
66+
EOF
67+
4668
# Switch back to vscode user
4769
USER vscode

.devcontainer/devcontainer.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,18 @@
2727
"NUGET_PACKAGES": "/home/vscode/.nuget/packages" // this might not be needed. will try removing later.
2828
},
2929
"mounts": [
30-
"source=crucible-dev-microsoft,target=/home/vscode/.microsoft,type=volume", // persist usersecrets across container rebuilds
31-
"source=crucible-dev-data,target=/mnt/data/,type=volume"
30+
// crucible repo data
31+
"source=crucible-dev-data,target=/mnt/data/,type=volume",
32+
// Usersecrets
33+
"source=crucible-dev-microsoft,target=/home/vscode/.microsoft,type=volume",
34+
// Shell history
35+
"source=crucible-dev-shell-history,target=/home/vscode/.history,type=volume"
3236
],
3337
"postCreateCommand": "bash -l .devcontainer/postcreate.sh",
3438
"postStartCommand": "bash -l .devcontainer/poststart.sh",
35-
"forwardPorts": [9003], // ✅ Added this line for Xdebug
39+
"forwardPorts": [
40+
9003
41+
], // ✅ Added this line for Xdebug
3642
"customizations": {
3743
"vscode": {
3844
"extensions": [

.devcontainer/postcreate.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ scripts/clone-repos.sh
1010
scripts/add-moodle-mounts.sh
1111

1212
dotnet tool install -g Aspire.Cli
13+
# Install dotnet-ef globally
14+
dotnet tool install --global dotnet-ef --version 10
1315
dotnet dev-certs https --trust
1416

1517
npm config -g set fund false
@@ -30,9 +32,6 @@ else
3032
echo "No custom CA certificates found in ${CUSTOM_CERT_SOURCE}; skipping copy."
3133
fi
3234

33-
# Install dotnet-ef globally
34-
dotnet tool install --global dotnet-ef --version 10
35-
3635
# Welcome message
3736
cat <<'EOF'
3837

0 commit comments

Comments
 (0)