From 669c2e028d1a57e05c4307fd864dc056ab5ea6da Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Wed, 11 Oct 2023 15:19:34 +0000 Subject: [PATCH 1/4] tidier prompt management --- .devcontainer/.bashrc | 18 +++++++++++++++--- .devcontainer/devcontainer.json | 3 ++- user_examples/.bashrc_dev_container | 13 ------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.devcontainer/.bashrc b/.devcontainer/.bashrc index 27e6e8b..260709f 100644 --- a/.devcontainer/.bashrc +++ b/.devcontainer/.bashrc @@ -1,7 +1,8 @@ ################################################################################ # epics-containers developer shell configuration. -# This is a standard ubuntu .bashrc plus a call to .bashrc_dev_container -# in the user's home directory on the host machine. +# This is a standard ubuntu .bashrc plus a PS1 prompt with container name +# and a call to .bashrc_dev_container in the user's home directory on the +# host machine. ################################################################################ # ~/.bashrc: executed by bash(1) for non-login shells. @@ -62,10 +63,21 @@ if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi +function parse_git_branch { + git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' +} + +# make a useful prompt, including current container name +EC_PROJECT=${EC_PROJECT:-container} +PS1="\[\e[32m\]\$(parse_git_branch)\[\e[m\][\[\e[34m\]\[\e[m\]\W]\$ " +export PS1="[\[\e[31m\]${EC_PROJECT#'ioc-'}\[\e[m\]]${PS1}" +source /root/.bash_completions/ibek.sh + # add user's custom .bashrc_dev_container if [ -f ~/.bashrc_dev_container ]; then . ~/.bashrc_dev_container fi -source /root/.bash_completions/ibek.sh + + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d111abe..94c6bdc 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,7 +9,8 @@ } }, "remoteEnv": { - "DISPLAY": "${localEnv:DISPLAY}" + "DISPLAY": "${localEnv:DISPLAY}", + "EC_PROJECT": "${localWorkspaceFolderBasename}" }, "customizations": { "vscode": { diff --git a/user_examples/.bashrc_dev_container b/user_examples/.bashrc_dev_container index 1a69a91..0ca306a 100644 --- a/user_examples/.bashrc_dev_container +++ b/user_examples/.bashrc_dev_container @@ -26,16 +26,3 @@ if [[ ! -f /tmp/git-completion.bash ]]; then wget -q -P /tmp https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash fi source /tmp/git-completion.bash - -# add ibek completion if available -( source <(ibek --show-completion bash) ) &> /dev/null - -function parse_git_branch { - git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' -} - -# make a useful prompt, including current container name -PS1="\[\e[32m\]\$(parse_git_branch)\[\e[m\][\[\e[34m\]\[\e[m\]\W]\$ " -export PS1="[\[\e[31m\]${PROJECT_NAME:-container}\[\e[m\]]${PS1}" - - From 1730d5582f588bfec7755fa59d3687dfd11daeb6 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Wed, 11 Oct 2023 15:22:30 +0000 Subject: [PATCH 2/4] sync with template --- .devcontainer/.bashrc | 3 --- .github/workflows/build.sh | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.devcontainer/.bashrc b/.devcontainer/.bashrc index 260709f..8afa0af 100644 --- a/.devcontainer/.bashrc +++ b/.devcontainer/.bashrc @@ -78,6 +78,3 @@ if [ -f ~/.bashrc_dev_container ]; then . ~/.bashrc_dev_container fi - - - diff --git a/.github/workflows/build.sh b/.github/workflows/build.sh index 55c8efc..964fc4f 100755 --- a/.github/workflows/build.sh +++ b/.github/workflows/build.sh @@ -20,6 +20,7 @@ if [[ "${PUSH}" == 'true' ]] ; then EC_PUSH='--push' ; fi THIS=$(dirname ${0}) set -xe +mkdir -p ${CACHE} # get the current version of ec CLI pip install -r ${THIS}/../../requirements.txt From 29e166891c9fdae8301cd27187c7d1bd4029c69f Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Thu, 12 Oct 2023 11:44:21 +0000 Subject: [PATCH 3/4] try to make pythonpath for ioc-project --- .vscode/settings.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index f2785aa..7a77d43 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,4 +7,5 @@ "titleBar.activeBackground": "#800E42", "titleBar.activeForeground": "#FFFCFD" }, + "python.pythonPath": "/venv/bin/python3", } \ No newline at end of file From e280f0525800cda91e1932d55ebab5ce1753be3f Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Fri, 13 Oct 2023 03:59:45 +0000 Subject: [PATCH 4/4] add comments to devcontainer.json --- .devcontainer/.bashrc | 2 ++ .devcontainer/devcontainer.json | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.devcontainer/.bashrc b/.devcontainer/.bashrc index 8afa0af..9c4a80f 100644 --- a/.devcontainer/.bashrc +++ b/.devcontainer/.bashrc @@ -78,3 +78,5 @@ if [ -f ~/.bashrc_dev_container ]; then . ~/.bashrc_dev_container fi + + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 94c6bdc..b32b965 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,7 +9,9 @@ } }, "remoteEnv": { + // allows X11 apps to run inside the container "DISPLAY": "${localEnv:DISPLAY}", + // provides a name for epics-containers to use in bash prompt etc. "EC_PROJECT": "${localWorkspaceFolderBasename}" }, "customizations": { @@ -30,23 +32,36 @@ } }, // Make sure the files we are mapping into the container exist on the host + // You can place any other outside of the container before-launch commands here "initializeCommand": "bash .devcontainer/initializeCommand ${devcontainerId}", + // Hooks the global .bashprofile_dev_container but also can add any other commands + // to run in the container at creation in here "postCreateCommand": "bash .devcontainer/postCreateCommand ${devcontainerId}", "runArgs": [ + // Allow the container to access the host X11 display and EPICS CA "--net=host", + // Make sure podman can see all host filesystems. WARNING: not compatible with docker "--security-opt=label=disable" ], "workspaceMount": "source=${localWorkspaceFolder},target=/epics/${localWorkspaceFolderBasename},type=bind", "workspaceFolder": "/epics/${localWorkspaceFolderBasename}", "mounts": [ // Mount some useful local files from the user's home directory + // By mounting the parent of the workspace we can work on multiple peer projects "source=${localWorkspaceFolder}/../,target=/repos,type=bind", + // this provides eternal bash history in and out of the container "source=${localEnv:HOME}/.bash_eternal_history,target=/root/.bash_eternal_history,type=bind", + // this bashrc hooks up the .bashrc_dev_container in the following mount "source=${localWorkspaceFolder}/.devcontainer/.bashrc,target=/root/.bashrc,type=bind", + // provides a place for you to put your shell customizations for all your dev containers "source=${localEnv:HOME}/.bashrc_dev_container,target=/root/.bashrc_dev_container,type=bind", + // provides a place to install any packages you want to have across all your dev containers "source=${localEnv:HOME}/.bashprofile_dev_container,target=/root/.bashprofile_dev_container,type=bind", + // ensures your git name and email are set correctly "source=${localEnv:HOME}/.gitconfig,target=/root/.gitconfig,type=bind", + // provides the same command line editing experience as your host "source=${localEnv:HOME}/.inputrc,target=/root/.inputrc,type=bind", + // provides the same ssh keys as your host "source=${localEnv:HOME}/.ssh,target=/root/.ssh,type=bind" ] } \ No newline at end of file