Hi @leictreonaic.
The Arduino IDE developers are tracking the request to add such a configuration feature here:
It is actually a fairly common convention used by text editors and IDEs.
There isn't a good way to do it. However, there are a couple of ways you might get the behavior you want by using the current capabilities of Arduino IDE. I'll describe them below in case you are interested:
Cause IDE to Always Open a Specific Sketch
This isn't exactly what you want, but I think it is the closest you can get with a reasonable approach.
When you pass the path of a sketch as an argument to the Arduino IDE invocation, it will open that sketch instead of restoring the previous session as usual.
You would create a dedicated sketch that serves as your "new" sketch that is opened by Arduino IDE on startup. Create a Windows file shortcut, Linux desktop icon, etc. for the Arduino IDE application. Configure the file shortcut to the path of that sketch to the Arduino IDE executable.
Clear List Of Last Sketches
As for an unreasonable/hacky approach, you could create a system that automatically clears the data from the files where Arduino IDE stores the paths of the sketches to restore on open.
There is a detailed technical explanation of how this data is stored and used here:
https://forum.arduino.cc/t/incorrect-default-sketch-opened-when-starting-ide/1127463/10
To summarize, the data is stored in:
- The
recentRoots
field of<configuration folder>/recentworkspace.json
- The
workspaces
field of<user data folder>/config.json
I was able to accomplish the desired behavior by opening the files in a text editor, manually removing the data from recentworkspace.json#/recentRoots[]
and config.json#/workspaces[]
, then setting the read-only file attribute on those files to stop Arduino IDE from later being able to write new data. From some quick tests, it appears that crude approach does work, but it causes Arduino IDE to produce some error messages that might be annoying or alarming to the user.
- The
recentRoots
field of<configuration folder>/recentworkspace.json
- The
workspaces
field of<user data folder>/config.json
So a better approach might be to leave the files writable, but set up a system to automatically clear the data before starting Arduino IDE.
If you want to get fancy, you could use a tool like jq to clear the specific fields of these files. But you can also just delete the two files entirely without causing any problem.
"Configuration Folder" Location
Linux
/home/<username>/.arduinoIDE/
(where <username>
is your Linux username)
The
.arduinoIDE
folder may be hidden by default in your file manager and terminal.
macOS
/Users/<username>/.arduinoIDE/
(where <username>
is your macOS username)
The
.arduinoIDE
folder is hidden by default. You can make it visible by pressing the Command+Shift+. keyboard shortcut.
Windows
C:\Users\<username>\.arduinoIDE\
(where <username>
is your Windows username)
"User Data folder" location:
Linux
/home/<username>/.config/arduino-ide/
(where <username>
is your Linux username)
The
.config
folder may be hidden by default in your file manager and terminal.
macOS
/Users/<username>/Library/Application Support/arduino-ide/
(where <username>
is your macOS username)
The
Library
folder is hidden by default. You can make it visible by pressing the Command+Shift+. keyboard shortcut.
Windows
C:\Users\<username>\AppData\Roaming\arduino-ide\
(where <username>
is your Windows username)
If looking for it with your file manager or command line, note that the
AppData
folder is hidden by default. On Windows "File Explorer", you can make it visible by opening the "View" menu, then checking the box next to "☐ Hidden items".