Skip to content

Instantly share code, notes, and snippets.

@bketelsen
Created May 1, 2025 14:26
Show Gist options
  • Save bketelsen/c544ddb99158829b3825bf7628ce3461 to your computer and use it in GitHub Desktop.
Save bketelsen/c544ddb99158829b3825bf7628ce3461 to your computer and use it in GitHub Desktop.
bash scripts for devcontainers
#!/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