0

I've searched high and low and tried several other solutions for this but can't seem to find an answer.

In MacOS, I have iTerm2 set to use zsh as my main terminal, with powerelevel10k theme, and oh-my-zsh managing it, not sure if this info will help, but wanted to include it.

I'm trying to set environmental variables, and it keeps giving me the following:

> export $FOO=bar
zsh: bar not found

It doesn't matter what the variable or the value is, it continues to tell me <variable> not found

As far as I can tell, I may have to modify my .zshrc file, but I'm lost at this point because I've tried several different solutions here on StackOverflow, and none of them have fixed it. Any ideas on how I can set env variables?

glitchwizard
  • 421
  • 1
  • 6
  • 23
  • 1
    Use `$` to *get* the value of a variable, not when setting, exporting, etc. Use `export FOO=bar` (note: *no* dollar signs anywhere there). – Gordon Davisson Apr 13 '21 at 16:29
  • *facepalm* I'm new to this, thank you @GordonDavisson – glitchwizard Apr 13 '21 at 16:32
  • @GordonDavisson that was the solution, if you want to write it up I'll mark it as the solution here for this question – glitchwizard Apr 13 '21 at 16:33
  • This is a common mistake, so it's probably better to mark this as a duplicate. BTW, I strongly recommend running your code through [shellcheck.net](https://www.shellcheck.net), as it's good at pointing out common problems (though it misses this particular one). – Gordon Davisson Apr 13 '21 at 16:42
  • @GordonDavisson thanks! I'll check out that site, much appreciated – glitchwizard Apr 13 '21 at 16:52

0 Answers0