Search code examples
zsh

How to source a string path in shell?


I want to do things like this:

local_config="~/.local_config"
source $local_config

But it seems that the string is not treated as a file path.

I'm using Zsh.


Solution

  • ~ is not expanded inside the single or double quotes. To make it work, keep ~ outside the quotes as:

    local_config=~"/.local_config"