Created
May 1, 2025 14:26
-
-
Save bketelsen/c544ddb99158829b3825bf7628ce3461 to your computer and use it in GitHub Desktop.
bash scripts for devcontainers
This file contains hidden or 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
#!/bin/bash | |
# copy dev container files from the template directory into the current directory | |
dc() { | |
local template_dir=~/projects/templates | |
# get the first argument | |
local template=$1 | |
if [ -z "$template" ]; then | |
echo "Please provide a template parameter. Options:" | |
# list all the templates in the template directory | |
ls -1 $template_dir | |
return | |
fi | |
# check if the template directory exists | |
if [ -d "$template_dir" ]; then | |
# check if the template exists | |
if [ -d "$template_dir/$template" ]; then | |
# copy the template directory to the current directory | |
cp -r "$template_dir/$template/." . | |
echo "Copied $template to $(pwd)" | |
else | |
echo "Template $template does not exist in $template_dir" | |
fi | |
else | |
echo "Template directory $template_dir does not exist" | |
fi | |
} | |
dccd() { | |
local template_dir=~/projects/templates | |
# get the first argument | |
local template=$1 | |
# check if the template directory exists | |
if [ -d "$template_dir" ]; then | |
# check if the template exists | |
if [ -d "$template_dir/$template" ]; then | |
cd "$template_dir/$template" | |
else | |
echo "Template $template does not exist in $template_dir" | |
cd "$template_dir" | |
fi | |
else | |
echo "Template directory $template_dir does not exist" | |
fi | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment