Search code examples
bashaliasddev

Can I add e.g. aliases only once for multiple containers with ddev?


I have several projects where I use ddev. I want to configure bash-scripts and aliases like

alias ll="ls -lh"

for all projects. How can I do this?

My ddev Version is 1.14.2 and I am on a MAC with Bash 5.0.11 configured on my terminal.

I know if I use .ddev/homeadditions/.bash_aliases I have all aliases, which I configure in .bash_aliases, but I don't want to configure it again and again for each project.


Solution

  • DRUD did it. In Version 1.15 you can now add eg. global aliases or whatever you like, that matches .bash_profile .profile or other dotfiles in the home directory.

    You just have to move or copy the file:

    ~/.ddev/homeadditions/bash_aliases.example to ~/.ddev/homeadditions/.bash_aliases

    and add your aliasses there.

    Now, if your container already runs, use ddev restart to "copy" the global aliasfile to the specific container.

    If you need functions you can use that file too, like:

    function test() {
        clear
        echo "Some text"
        ls -lha
    }
    

    Thanks to @rfay