Here is the exact layout of what commands to execute in your terminal to get this working on your machine:
Step 1: Install Node.js, NPM, and PHP Utilities
You need the execution engines for both Javascript and PHP code management.
bash
sudo apt update && sudo apt install -y nodejs npm php-cliUse code with caution.
Step 2: Install Prettier Globally
Installs the core formatter engine to your global system path.
bash
sudo npm install -g prettierUse code with caution.
Step 3: Install the PHP Plugin for Prettier
By default, Prettier handles HTML, CSS, and JS. Running this command adds native support for PHP syntax.
bash
sudo npm install -g @prettier/plugin-phpUse code with caution.
Step 4: Run the All-In-One Global Command
Execute this to watch Prettier scan, clean, and fix every script file in your target location instantly.
bash
prettier --write "/home/sumnima/Desktop/**/*.{js,php,html,css}"Option 1: Format only the files inside this test folder (Recommended)
Since you are already inside ~/Desktop/test, you can use . (which means “current folder”) to target just these files:
bash
prettier --write "./**/*.{js,php,html,css}"Use code with caution.
(This will safely format your theme.css file without looking at the rest of your Desktop).
Use code with caution.
📘 Terminal Formatting Dictionary (Blog Post Reference)
Here is a quick-glance breakdown of what each terminal argument does under the hood when formatting your codebase:
prettier
The main executable command. It triggers the Prettier engine to analyze text files.--write
Tells the engine to modify files in place. If omitted, Prettier will only print the beautiful code into your terminal window instead of saving it.**/*
A wildcard expression called a “glob.” It tells the terminal to look inside the target directory and any nested subfolders.{js,php,html,css}
A brace expansion rule. It acts as an OR filter, meaning the command only touches files matching those exact extensions while ignoring images or zip folders.