CLI, I don’t get the setup right, am I?

Hi everybody. I just tried out the CLI. I followed the instruction on github – at least like I understand what’s written there :slightly_smiling_face:

  1. I opened my terminal an run composer global require getkirby/cli
  2. composer -n config --global home
  3. I opened a current project and export PATH=~/.composer/vendor/bin:$PATH
  4. kirby install and kirby version → works

But now if i switch to another project or close the terminal I have to redo the 3. step.
This works but seems quite awkward. Is this the way? What exactly is happening on step 3?
Sorry for asking. I’m familiar with the Terminal for stuff like npm run dev but I never use composer. And my English is a little lame.

The PATH environment variable tells your shell (the terminal) where to find executables.
With the above command you are setting PATH to "~/.composer/vendor/bin" plus what is already in PATH.
Essentially you are prepending the folder “~/.composer/vendor/bin” to it.
~ is a shortcut for your home folder (something like /Users/jwssnr).

This way the terminal knows it has to look for executable files also in the folder into which composer installed the kirby cli program. This allows you to just write kirby in the terminal, instead of having to write out the whole path ~/.composer/vendor/bin/kirby every time.

However, when you close the terminal or open a new one, the PATH variable is reset. And the shell does no longer know it has to search kirby in that folder.

You can however make it so that the above command is automatically executed every time you open a terminal, by adding it to a script that is automatically executed either every time you open a terminal, or simply once when you login.
I personally don’t use osx, but if I understand it correctly, one such script would be the .zshrc file in your home folder (e.g /Users/jwssnr). Please refer to this StackExchange answer in regards to scripts that are automatically executed: macos - ZSH: .zprofile, .zshrc, .zlogin - What goes where? - Ask Different

Thank you so much for your time.
Now I understand what this Path thing does. And that it’s meant to be like it is.
Was really insecure.

It’s not that hard to handle this 2 lines to bring kirby CLI to the current path.
So I’ll stick with this. :sunny: