How to add "platformio" / "pio" shortcut on Linux command line

Typically, when you want to use the pio executable from PlatformIO, you need to first activate the virtual environment using

activate_platformio_bash.sh
source ~/.platformio/penv/bin/activate

However, you can easily create a shortcut using a shell alias using:

For bash:

activate_platformio_zsh.sh
echo -e '\nalias platformio="source ~/.platformio/penv/bin/activate"\n' >> ~/.bashrc

For zsh:

run_platformio.sh
echo -e '\nalias platformio="source ~/.platformio/penv/bin/activate"\n' >> ~/.zshrc

Note that in order for the change to take effect, you need to restart your shell(or open a new shell).

Now you can use run

example.sh
platformio

and you’ll immediately have access to pio and other PlatformIO tools.


Check out similar posts by category: PlatformIO