-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor postAttachCommand * Refactor comment
- Loading branch information
Showing
2 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash -eu | ||
# | ||
# This script is executed as postAttachCommand in devcontainer.json | ||
# This script does... | ||
# - create symbolic link of config.yaml for easier development | ||
# - add command history setting to .zshrc to persist history | ||
# | ||
|
||
echo "creating symbolic link of config ZSHRC..." | ||
|
||
LINK_TARGET="$(pwd)/cmd/agent/core/ngt/sample.yaml" | ||
LINK_SRC="/etc/server/config.yaml" | ||
|
||
mkdir -p /etc/server | ||
|
||
if [ ! -e "$LINK_SRC" ]; then | ||
ln -s "$LINK_TARGET" "$LINK_SRC" | ||
echo "created symbolic link: $LINK_SRC -> $LINK_TARGET" | ||
else | ||
echo "$LINK_SRC already exists" | ||
fi | ||
|
||
|
||
echo "adding history setting to .zshrc..." | ||
|
||
LINE1="export HISTFILE=/commandhistory/.zsh_history" | ||
LINE2="setopt INC_APPEND_HISTORY" | ||
|
||
ZSHRC="/root/.zshrc" | ||
|
||
# write only if those lines don't exist | ||
grep -qxF "$LINE1" "$ZSHRC" || echo "$LINE1" >> "$ZSHRC" | ||
grep -qxF "$LINE2" "$ZSHRC" || echo "$LINE2" >> "$ZSHRC" | ||
|
||
echo "added history setting to .zshrc" |