As developers, we’re always looking for ways to streamline our workflow and eliminate those small friction points that add up over time. One common task that can be surprisingly tedious is opening your IDE with a specific project directory. If you’re using PHPStorm on macOS and find yourself constantly navigating through Finder or the IDE’s file picker, this simple solution will save you time every single day.
The Problem
How many times have you been working in the terminal, navigated to a project directory, and then had to:
- Open PHPStorm manually
- Click „Open“ or „Open Project“
- Navigate through the file picker to find your project
- Finally start coding
It’s not a huge deal, but it breaks your flow and wastes precious seconds that add up over time.
The Solution: A Custom Terminal Command
What if you could simply type storm .
in any directory and have PHPStorm open instantly with that project loaded? Well, you can! Here’s how to set up a custom terminal command that does exactly that.
Setting Up Your Custom PHPStorm Launcher
Step 1: Create the Script
First, create a new bash script. I’ll call it storm
for brevity, but you can name it whatever makes sense to you.
#!/bin/bash
# PHPStorm Launch Script
# Opens PHPStorm with the current directory
# If a parameter is passed, use it as the path
if [ "$1" == "." ]; then
# Current directory
DIRECTORY=$(pwd)
elif [ -n "$1" ]; then
# Specific directory
DIRECTORY="$1"
else
# Fallback: current directory
DIRECTORY=$(pwd)
fi
# Open PHPStorm
open -na "PhpStorm.app" --args "$DIRECTORY"
Step 2: Make It Executable and Accessible
Save this script as storm
(without any file extension) in a directory that’s in your system PATH. The most common location is /usr/local/bin/
:
# Save the script
sudo nano /usr/local/bin/storm
# Make it executable
chmod +x /usr/local/bin/storm
Step 3: Verify Your PATH
Make sure /usr/local/bin/
is in your PATH by running:
echo $PATH
If it’s not there, add it to your shell configuration file (.zshrc
for Zsh or .bash_profile
for Bash):
export PATH="/usr/local/bin:$PATH"
Then reload your shell configuration:
source ~/.zshrc # or ~/.bash_profile
How to Use Your New Command
Once everything is set up, you can use your new command in several ways:
storm .
– Opens PHPStorm with the current directorystorm /path/to/project
– Opens PHPStorm with a specific directorystorm
– Opens PHPStorm with the current directory (fallback behavior)
How It Works
The script leverages macOS’s built-in open
command, which is designed to open files and applications just like double-clicking them in Finder. The -na
flags tell macOS to:
-n
– Open a new instance of the application-a
– Specify the application name
The --args
parameter passes the directory path directly to PHPStorm, which automatically opens it as a project.
Customization Ideas
Want to take this further? Here are some ideas:
Different IDE Support
You could create similar scripts for other JetBrains IDEs:
# For WebStorm
open -na "WebStorm.app" --args "$DIRECTORY"
# For IntelliJ IDEA
open -na "IntelliJ IDEA.app" --args "$DIRECTORY"
Smart IDE Detection
Create a script that automatically chooses the right IDE based on the project type:
if [ -f "composer.json" ]; then
open -na "PhpStorm.app" --args "$DIRECTORY"
elif [ -f "package.json" ]; then
open -na "WebStorm.app" --args "$DIRECTORY"
else
open -na "PhpStorm.app" --args "$DIRECTORY"
fi
Error Handling
Add some error checking to make the script more robust:
# Check if PHPStorm is installed
if ! ls /Applications/ | grep -q "PhpStorm.app"; then
echo "PHPStorm not found in /Applications/"
exit 1
fi
# Check if directory exists
if [ ! -d "$DIRECTORY" ]; then
echo "Directory does not exist: $DIRECTORY"
exit 1
fi
Why This Matters
Small optimizations like this might seem trivial, but they compound over time. If you open projects 10 times a day and this saves you 10 seconds each time, that’s over 6 hours saved per year. More importantly, it maintains your flow state and keeps you focused on what really matters: writing great code.
Conclusion
Setting up custom terminal commands for your development tools is a simple way to boost your productivity. This PHPStorm launcher is just one example—the same principle can be applied to any application or workflow you use regularly.
Give it a try and see how much smoother your development workflow becomes. Your future self will thank you for those extra seconds saved and the reduced friction in your daily coding routine.
What other development workflow optimizations have you implemented? Share your favorite terminal shortcuts and productivity hacks in the comments below!