How to use DDEV custom commands and other goodies to add zsh
DDEV is a powerful local development tool that many of you are fond of for its simplicity and extensibility. Recent versions of DDEV (v1.10+) add custom commands and loads of other goodies we’d like to show you how to use. In this screencast and tutorial, we’ll show you how to make use of DDEV custom commands, adding web server packages, and adding extras in .ddev/homeadditions
to support your specific project needs.
When in doubt, update DDEV on your machine and run ddev config
on a project before getting started with new features.
As an example, and since there are many folks who absolutely love zsh and Oh My Zsh (an alternative Unix shell and an accompanying framework), we’ll demonstrate these features by showing you how to add zsh and Oh My Zsh to a DDEV project. We’re going to do three things to demonstrate this:
- Add the zsh Debian package into the web container with
webimage_extra_packages
- Add a custom command that works like
ddev ssh
, but it’s going to beddev zsh
- Add all the scaffolding for Oh My Zsh in the home directory for lovers of Oh My Zsh
Watch the video below and read the detailed instructions to configure your own project:
How to add zsh and Oh My Zsh to DDEV
-
From the root of an existing project configured with DDEV: Add the zsh package to the web server container by adding
webimage_extra_packages: ["zsh"]
to the.ddev/config.yaml
file (or runddev config --webimage-extra-packages=zsh
, which does the exact same thing). If you only want zsh in the web container, you canddev restart
and you’re done! -
To add a
ddev zsh
custom command to your project, place a file named “zsh” in.ddev/commands/web/zsh
with the following contents and make it executable withchmod +x zsh
:#!/bin/bash ## Description: ssh into web container using zsh ## Usage: zsh [flags] [args] ## Example: "ddev zsh" zsh $@
Now you can run
ddev zsh
and be in your familiar zsh environment (if you did theddev restart
after adding the package in step 1. -
If zsh is all you want, copy your favorite
.zshrc
into.ddev/homeadditions
for your project and zsh will be set up with your.zshrc
every time you start the project. You’re done now. -
Now to add all the goodies that make Oh My Zsh work:
- If you already have a
~/.oh-my-zsh
and~/.zshrc
, you can probably copy those into.ddev/homeadditions
and they will be added when you runddev start
. - Otherwise, create the
.oh-my-zsh
like this: cd .ddev/homeadditions
curl -Lo install.sh https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh
ZSH=./.oh-my-zsh sh ./install.sh --unattended
cp ~/.zshrc .
(This copies the.zshrc
thatinstall.sh
will have mistakenly put in your home directory.- Change the line near the top of the
.ddev/homeadditions/.zshrc
toexport ZSH=~/.oh-my-zsh
instead of what the oh-my-zsh installer generated.
- If you already have a
-
Now you can run
ddev start
andddev zsh
will have all the Oh My Zsh goodies.
To review, we used three advanced features of ddev:
- Added an extra Debian package (zsh) with
webimage_extra_packages
- Added a custom command (zsh) in
.ddev/commands/web
by adding a simple script (docs) - Added extra stuff (
oh-my-zsh
and.zshrc
) into.ddev/homeadditions
that will be added to the home directory in the web container on everyddev start
(docs).
Happy customizing! If you have questions, check out our support channels.