A comprehensive Zsh plugin that works with both Laravel Valet (Official) on macOS and Valet Linux on Ubuntu/Debian. Provides intelligent autocompletion, helpful aliases, and utility functions to streamline your local development workflow.
valet <TAB>
valet link <TAB> # Shows available options
valet secure <TAB> # Shows unsecured sites
valet unsecure <TAB> # Shows secured sites
- π Universal Compatibility - Works with both Laravel Valet (macOS) and Valet Linux
- π Smart Tab Completion - Context-aware autocompletion for all Valet commands
- π Quick Status Check - Instant overview of Valet services and configuration
- π Cross-Platform Site Opening - Open current directory's site in your browser
- π Easy Site Management - Quick link/secure operations from any directory
- π Service Monitoring - Real-time log viewing (adapts to your OS)
- β‘ Performance Optimized - Lazy loading for faster shell startup
- π§ Multi Plugin Manager Support - Works with all major Zsh plugin managers
- π Environment Detection - Automatically detects your Valet version and OS
- Zsh shell
- Laravel Valet (either version):
- macOS: Laravel Valet (Official)
- Linux: Valet Linux on Ubuntu/Debian
- Compatible OS: macOS 10.15+ or Ubuntu 18.04+/Debian 10+
git clone https://github.com/a909m/valet-zsh-plugin.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/valet
Add valet
to your plugins in ~/.zshrc
:
plugins=(... valet)
# Add to ~/.zshrc
zinit load "a909m/valet-zsh-plugin"
# Or with lazy loading for better performance
zinit ice wait lucid has'valet'
zinit load "a909m/valet-zsh-plugin"
# Add to ~/.zshrc
antigen bundle a909m/valet-zsh-plugin
antigen apply
# Add to ~/.zshrc
zplug "a909m/valet-zsh-plugin", defer:2
git clone https://github.com/a909m/valet-zsh-plugin.git ~/.zsh/plugins/valet
echo "source ~/.zsh/plugins/valet/valet.plugin.zsh" >> ~/.zshrc
Then reload your shell:
source ~/.zshrc
Alias | Command | Description |
---|---|---|
vs |
valet-status |
Show comprehensive Valet status |
vo |
valet-open |
Open current site in browser |
vlh |
valet-link-here |
Link current directory |
vsh |
valet-secure-here |
Secure current site with HTTPS |
vl |
valet links |
List all linked sites |
vp |
valet paths |
List all parked paths |
vlog |
valet-logs |
View service logs |
vinfo |
valet-info |
Show environment information |
# Quick status check
vs
# Link current directory as 'myproject'
vlh myproject
# Open current site in browser
vo
# Secure current site
vsh
# View nginx error logs
vlog nginx
# View PHP-FPM logs
vlog php
# All valet commands have smart completion
valet <TAB>
valet link <TAB> # Shows available options
valet secure <TAB> # Shows unsecured sites
valet unsecure <TAB> # Shows secured sites
Displays a comprehensive overview of your Valet installation with OS-specific service detection:
macOS Output:
π Valet Status (Laravel Valet (Official) on macOS):
Plugin Manager: oh-my-zsh
=============================================
β
Valet is installed
β
nginx is running
β
dnsmasq is running
β
php is running
π Domain: .test
π Linked sites: 5
π Parked paths: 2
π PHP: PHP 8.2.0
Linux Output:
π Valet Status (Valet Linux on Linux):
Plugin Manager: zinit
============================================
β
Valet is installed
β
nginx is running
β
dnsmasq is running
β
php8.1-fpm is running
π Domain: .test
π Linked sites: 5
π Parked paths: 2
π PHP: PHP 8.1.2
Opens the current directory's site in your default browser. Automatically detects HTTP/HTTPS and handles different browsers across platforms (uses open
on macOS, xdg-open
on Linux).
Shows detailed environment information:
π Valet Environment Information:
=================================
Operating System: macOS
Valet Version: Laravel Valet (Official)
Plugin Manager: oh-my-zsh
Plugin Directory: ~/.oh-my-zsh/custom/plugins/valet
Valet Binary: /usr/local/bin/valet
Valet Version Output: Laravel Valet 3.3.2
PHP Information:
PHP Binary: /opt/homebrew/bin/php
PHP Version: PHP 8.2.0 (cli)
Links the current directory to Valet. Optionally accepts a custom name:
vlh # Links as current directory name
vlh custom-name # Links as 'custom-name'
View real-time logs for Valet services with OS-specific paths:
macOS:
vlog nginx # View Nginx logs from Homebrew paths
vlog php # View PHP-FPM logs from Homebrew paths
Linux:
vlog nginx # View Nginx error logs from /var/log/nginx/
vlog php-fpm # View PHP-FPM logs (auto-detects active version)
# Disable loading message
export VALET_PLUGIN_SILENT_LOAD=true
# Enable auto-updates (if plugin is git-cloned)
export VALET_PLUGIN_AUTO_UPDATE=true
# Set default TLD for valet-open function
export VALET_PLUGIN_DEFAULT_TLD=test
- Uses Homebrew service management (
brew services
) - Supports
valet use
command for PHP version switching - Automatically detects Homebrew paths for logs
- Uses
open
command for browser launching
- Uses systemctl for service management
- Supports
valet status
command - Includes database management commands (
valet db
) - Detects multiple PHP-FPM versions automatically
- Uses
xdg-open
for browser launching
Customize the plugin behavior with environment variables in your ~/.zshrc
:
# Disable loading message
export VALET_PLUGIN_SILENT_LOAD=true
# Enable auto-updates (if plugin is git-cloned)
export VALET_PLUGIN_AUTO_UPDATE=true
# Set default TLD for valet-open function
export VALET_PLUGIN_DEFAULT_TLD=test
Extend the plugin by adding your own functions to ~/.zshrc
:
# Custom function to quickly restart all Valet services
valet-restart-all() {
echo "π Restarting all Valet services..."
valet restart
echo "β
All services restarted!"
}
# Quick database creation for current project (Linux only)
valet-db-create() {
if [[ "$VALET_OS" == "Linux" ]]; then
local db_name=${1:-$(basename $PWD)}
echo "ποΈ Creating database: $db_name"
valet db create "$db_name"
else
echo "Database commands are only available on Valet Linux"
fi
}
# Platform-specific PHP switching
valet-switch-php() {
local version=$1
if [[ "$VALET_OS" == "macOS" ]]; then
valet use "$version"
else
valet php "$version"
fi
}
Add your own aliases:
alias vr='valet restart'
alias vdb='valet db'
alias vphp='valet php'
-
Check Valet Installation:
which valet valet --version # Check plugin detection vinfo
-
Verify Plugin Location:
# For Oh My Zsh ls -la ~/.oh-my-zsh/custom/plugins/valet/ # For manual installation ls -la ~/.zsh/plugins/valet/
-
Test Plugin Manually:
source path/to/valet.plugin.zsh
- Homebrew not found: Ensure Homebrew is installed and in PATH
- Services not starting: Check
brew services list
- PHP version conflicts: Use
valet use php@8.2
to specify version
- SystemD services: Ensure you have permission to check service status
- Multiple PHP versions: Plugin auto-detects active PHP-FPM version
- Log file permissions: Add user to appropriate groups:
sudo usermod -a -G adm $USER sudo usermod -a -G www-data $USER
-
Reload completion system:
rm ~/.zcompdump* exec zsh
-
Check if completion is registered:
complete -p valet
-
Test completion manually:
# Type and press TAB valet <TAB> valet link <TAB>
If you encounter permission issues with logs:
# macOS (if using custom Homebrew installation)
sudo chown -R $(whoami) /opt/homebrew/var/log/
sudo chown -R $(whoami) /usr/local/var/log/
# Linux
sudo usermod -a -G adm $USER
sudo usermod -a -G www-data $USER
# Logout and login again for group changes to take effect
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
# Clone your fork
git clone https://github.com/a909m/universal-valet-zsh-plugin.git
cd universal-valet-zsh-plugin
# Test the plugin on your platform
zsh -c "source valet.plugin.zsh && valet-status"
zsh -c "source valet.plugin.zsh && vinfo"
# Run tests (if available)
./test-compatibility.sh
When adding new features:
- Follow existing naming conventions (
valet-*
for functions) - Add appropriate completion support for both platforms
- Use OS detection (
$VALET_OS
and$VALET_VERSION
) for platform-specific code - Update the README with examples for both macOS and Linux
- Test with multiple plugin managers
- Ensure backward compatibility
- Initial release with universal compatibility
- Smart tab completion for all Valet commands (macOS & Linux)
- Cross-platform helper functions and aliases
- Multi plugin manager support
- Lazy loading for better performance
- Automatic OS and Valet version detection
- Platform-specific service management and log viewing
- WSL Users: Some browser opening functions may not work in WSL environments
- Service Detection: Service management commands may vary on different Linux distributions
- Log Paths: Log file paths might differ on non-standard installations
- macOS ARM vs Intel: Plugin auto-detects Homebrew paths for both architectures
- Multiple PHP Versions: Linux users with multiple PHP-FPM versions - plugin detects the active one
- Laravel Valet (Official) - The original macOS Valet
- Valet Linux - The Linux port by Carlos Priego
- Oh My Zsh - Framework for managing Zsh configuration
- Zinit - Fast Zsh plugin manager
This project is licensed under the MIT License - see the LICENSE file for details.
- Created with assistance from Claude AI
- Inspired by the Laravel Valet community
- Thanks to all contributors and testers
- π Bug Reports: Open an issue
- π‘ Feature Requests: Start a discussion
- π Documentation: Check the Wiki
β Star this repo if you find it useful!
Made with β€οΈ for the Laravel community
Compatible with Laravel Valet (macOS) and Valet Linux