From 594200f88dcb69c16f6caffc37085de994f03a46 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Sun, 25 May 2025 18:56:28 +0200 Subject: [PATCH] Added devcontainer helper function --- zsh/dot-zshrc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/zsh/dot-zshrc b/zsh/dot-zshrc index aa5def8..01bab38 100644 --- a/zsh/dot-zshrc +++ b/zsh/dot-zshrc @@ -53,3 +53,22 @@ export EDITOR=nvim # export GREP_COLORS="mt=01;32" 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