Double-click a .php file in Nemo: this setup opens it in PhpStorm only
if PhpStorm is already running, or falls back to Geany otherwise.
The idea is that whenever I just want a quick edit, I don't want to load PhpStorm. And whenever I'm really coding, PhPStorm is already open.
mkdir -p ~/.local/bin
cat > ~/.local/bin/open-php << 'EOF'
#!/bin/bash
# Open .php files: use PhpStorm if running, otherwise Geany
if pgrep -x "phpstorm" > /dev/null || pgrep -f "phpstorm" > /dev/null; then
phpstorm "$@"
else
geany "$@"
fi
EOF
chmod +x ~/.local/bin/open-phpNote: the PhpStorm process name may vary depending on how it was installed (JetBrains Toolbox, standalone, snap...). Check the actual process name while PhpStorm is running with:
pgrep -a -f [Pp]hp[Ss]tormAdjust the
pgrepcalls in the script accordingly.
cat > ~/.local/share/applications/open-php.desktop << 'EOF'
[Desktop Entry]
Name=Open PHP File
Exec=/home/YOUR_USERNAME/.local/bin/open-php %F
Type=Application
NoDisplay=true
MimeType=application/x-php;text/x-php;
EOFReplace YOUR_USERNAME with your actual username
update-desktop-database ~/.local/share/applications
xdg-mime default open-php.desktop application/x-php
xdg-mime default open-php.desktop text/x-php