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
zshDebian package into the web container withwebimage_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
zshpackage to the web server container by addingwebimage_extra_packages: ["zsh"]to the.ddev/config.yamlfile (or runddev config --webimage-extra-packages=zsh, which does the exact same thing). If you only wantzshin the web container, you canddev restartand you’re done! -
To add a
ddev zshcustom command to your project, place a file namedzshin.ddev/commands/web/zshwith 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 zshand be in your familiar Zsh environment (if you did theddev restartafter adding the package in step 1. -
If Zsh is all you want, copy your favorite
.zshrcinto.ddev/homeadditionsfor your project and Zsh will be set up with your.zshrcevery 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-zshand~/.zshrc, you can probably copy those into.ddev/homeadditionsand they will be added when you runddev start. - Otherwise, create the
.oh-my-zshlike this: cd .ddev/homeadditionscurl -Lo install.sh https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.shZSH=./.oh-my-zsh sh ./install.sh --unattendedcp ~/.zshrc .(This copies the.zshrcthatinstall.shwill have mistakenly put in your home directory.- Change the line near the top of the
.ddev/homeadditions/.zshrctoexport ZSH=~/.oh-my-zshinstead of what the oh-my-zsh installer generated.
- If you already have a
-
Now you can run
ddev startandddev zshwill have all the Oh My Zsh goodies.
To review, we used three advanced features of ddev:
- Added an extra Debian package (
zsh) withwebimage_extra_packages - Added a custom command (
zsh) in.ddev/commands/webby adding a simple script (docs) - Added extra stuff (
oh-my-zshand.zshrc) into.ddev/homeadditionsthat 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.