How to auto add "lib_dir" to ino?

Sorry for the dense question.

When creating a new project I would like the following line to be auto added to my platformio.io file:

[platformio]
src_dir=.
lib_dir=~/Documents/Arduino/Libraries

How do I do that?
Thank you.

PS: i have searched the docs but found them confusing :wink:

platformio init command doesn’t provide this functionality. You can create alias of this command with echo "......" > platformio.ini snippet.

thank you for the reply.

being dense again…

echo “…” > platformio.ini snippet.

do you mean just make a regular snippet and manually enter it?

thank you again.

What is your OS? See Aliases

Mac. thanks for the link, that’ll take a while to penetrate my skull. :wink:

thanks again.

I mean to add to ~/.bash_profile this

> alias pioforarduino='pio init && echo \\n"[platformio]"\\n"src_dir=."\\n"lib_dir=~/Documents/Arduino/Libraries"\\n >> platformio.ini'

and then call

> pioforarduino

thank you again, but it’s not working, it’s something I’m doing wrong for sure.

i just made a snippet and will just fill it in manually.

sorry for wasting your time, your help is appreciated though.

Do you need any help?

since you asked, and this is going to open a can of worms, and i’m having a hard time putting together the pieces to explain

first thing is when do i run the alias i get this out out from the console

he current working directory /Users/rgilmore will be used for project.
You can specify another project directory via
`platformio init -d %PATH_TO_THE_PROJECT_DIR%` command.

The next files/directories will be created in /Users/rgilmore
platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-|
src - Put your source files here
lib - Put here project specific (private) libraries
Do you want to continue? [y/N]:

When I answer “yes” and open the file to check the output it looks like this in the platformio.ino file in root.

n[platformio]nsrc_dir=.nlib_dir=~/Documents/Arduino/Librariesn

there is more i could go on with but I’m not sure if it’s relevant yet.

thanks again, so glad i donated cause you guys are awesome!

Sorry, need to place double quotes. See updated comment.

Thanks a lot! :blush:

ok, now the entries are in the global platformio.ini correctly.

When I start a new project should those directories be showing up in the local project’s platformio.ini?

  1. Did you update bash profile according to How to auto add "lib_dir" to ino? - #6 by ivankravets ?
  2. Try to restart system terminal and changes will be applied.

sorry, i was in the middle of editing that post :wink:

Off-top question: Why do you need it? :blush: Why don’t use PlatformIO Library Manager?

Some of my libraries aren’t in there.

  1. You can request to add missed libs here Issues · platformio/platformio-libmirror · GitHub
  2. You can place missed libs to global folder ~/.platformio/libs (similar as ~/Documents/Arduino/Libraries)

ok, i’ll look into that avenue.

thank you again. :wink: