Skip to content

Commit

Permalink
added devcontainer config for Bill's docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
BillYJT committed May 20, 2023
1 parent 4f65e1e commit ad823e8
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .devcontainer/config/better_prompt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# File Name:
# better_prompt.sh
#
# Details:
# Contains a function to configure the bash prompt for dev work

# `````````````````````````````````````````````````````````````````````````````
# Function name:
# set_bash_prompt()
#
# Description:
# Configures the bash prompt for development. Sets up the CWD, the current
# git branch, any active Python virtual environment, and the username.
#
# [CWD:BRANCH:VENV][USER:HOSTNAME 🚀] _
#
# Example:
# [/workspaces:master:my_venv][root 🚀]
# Usage:
# Copy and paste the following function **and** the export command into
# your .bashrc file
#
function set_bash_prompt() {
# Color codes for easy prompt building
COLOR_DIVIDER="\[\e[30;1m\]"
COLOR_USERNAME="\[\e[34;1m\]"
COLOR_GITBRANCH="\[\e[33;1m\]"

Check failure on line 27 in .devcontainer/config/better_prompt.sh

View workflow job for this annotation

GitHub Actions / Spell checking

`GITBRANCH` is not a recognized word. (unrecognized-spelling)
COLOR_VENV="\[\e[36;1m\]"
COLOR_GREEN="\[\e[32;1m\]"
COLOR_PATH_OK="\[\e[32;1m\]"
COLOR_PATH_ERR="\[\e[31;1m\]"
COLOR_NONE="\[\e[0m\]"

# Change the path color based on return value.
if test $? -eq 0 ; then
PATH_COLOR=${COLOR_PATH_OK}
else
PATH_COLOR=${COLOR_PATH_ERR}
fi

# Set the PS1 to be "[workingdirectory:"

Check failure on line 41 in .devcontainer/config/better_prompt.sh

View workflow job for this annotation

GitHub Actions / Spell checking

`workingdirectory` is not a recognized word. (unrecognized-spelling)
PS1="${COLOR_DIVIDER}[${PATH_COLOR}\w${COLOR_DIVIDER}"
# Add git branch portion of the prompt, this adds ":branchname"

Check failure on line 43 in .devcontainer/config/better_prompt.sh

View workflow job for this annotation

GitHub Actions / Spell checking

`branchname` is not a recognized word. (unrecognized-spelling)
if ! git_loc="$(type -p "$git_command_name")" || [ -z "$git_loc" ]; then
# Git is installed
if [ -d .git ] || git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
# Inside of a git repository
GIT_BRANCH=$(git symbolic-ref --short HEAD)
PS1="${PS1}:${COLOR_GITBRANCH}${GIT_BRANCH}${COLOR_DIVIDER}"
fi
fi

# Add Python VirtualEnv portion of the prompt, this adds ":venvname"

Check failure on line 53 in .devcontainer/config/better_prompt.sh

View workflow job for this annotation

GitHub Actions / Spell checking

`venvname` is not a recognized word. (unrecognized-spelling)
if ! test -z "$VIRTUAL_ENV" ; then
PS1="${PS1}:${COLOR_VENV}`basename \"$VIRTUAL_ENV\"`${COLOR_DIVIDER}"
fi

# Close out the prompt, this adds "]\n[username 🚀] "
PS1="${PS1}]${COLOR_DIVIDER}[${COLOR_USERNAME}\u${COLOR_DIVIDER} 🚀]${COLOR_NONE} "
}

# Tell Bash to run the above function for every prompt
export PROMPT_COMMAND=set_bash_prompt
30 changes: 30 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:

Check failure on line 1 in .devcontainer/devcontainer.json

View workflow job for this annotation

GitHub Actions / Spell checking

`devcontainer` is not a recognized word. (unrecognized-spelling)
// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/ubuntu
{
"name": "fprime-docker",
"image": "billyjt/msp-fprime-docker:latest",

Check failure on line 5 in .devcontainer/devcontainer.json

View workflow job for this annotation

GitHub Actions / Spell checking

`msp` is not a recognized word. (unrecognized-spelling)

Check failure on line 5 in .devcontainer/devcontainer.json

View workflow job for this annotation

GitHub Actions / Spell checking

`billyjt` is not a recognized word. (unrecognized-spelling)

// Provides runtime arguments to the container
"runArgs": [
"--privileged",
"--network=host",
"--cap-add=SYS_PTRACE",

Check failure on line 11 in .devcontainer/devcontainer.json

View workflow job for this annotation

GitHub Actions / Spell checking

`PTRACE` is not a recognized word. (unrecognized-spelling)
"--security-opt=seccomp:unconfined",

Check failure on line 12 in .devcontainer/devcontainer.json

View workflow job for this annotation

GitHub Actions / Spell checking

`seccomp` is not a recognized word. (unrecognized-spelling)
"--security-opt=apparmor:unconfined"

Check failure on line 13 in .devcontainer/devcontainer.json

View workflow job for this annotation

GitHub Actions / Spell checking

`apparmor` is not a recognized word. (unrecognized-spelling)
],

// Set *default* container specific settings.json values on container create.
"settings": {},

// Add the IDs of extensions you want installed when the container is created.
"extensions": ["ms-vscode.cpptools-extension-pack"],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "cat .devcontainer/config/better_prompt.sh >> ~/.bashrc; python3 -m pip install -U -r /workspaces/fprime/requirements.txt"

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"
}

0 comments on commit ad823e8

Please sign in to comment.