Added devcontainer helper function

This commit is contained in:
Dreaded_X 2025-05-25 18:56:28 +02:00
parent a0421469c0
commit 594200f88d
Signed by: Dreaded_X
GPG Key ID: 5A0CBFE3C3377FAA

View File

@ -53,3 +53,22 @@ export EDITOR=nvim
# export GREP_COLORS="mt=01;32" # export GREP_COLORS="mt=01;32"
alias cl="clear" alias cl="clear"
if hash devcontainer 2>/dev/null; then
dc() {
ORIG_DIR="$PWD"
while [[ "$PWD" != / ]] ; do
if find "$PWD"/ -maxdepth 1 -type d -name ".devcontainer" | grep -q ".devcontainer"; then
WORKSPACE_FOLDER="$PWD"
builtin cd "$ORIG_DIR"
devcontainer exec --workspace-folder "$WORKSPACE_FOLDER" $@
return 0
else
builtin cd ..
fi
done
builtin cd "$ORIG_DIR"
echo "Unable to find workspace folder"
return 1
}
fi