mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-01-26 11:14:08 +00:00
chore(config): fish: add ivuorinen/phpenv.fish
Signed-off-by: Ismo Vuorinen <ismo@ivuorinen.net>
This commit is contained in:
123
config/fish/completions/phpenv.fish
Normal file
123
config/fish/completions/phpenv.fish
Normal file
@@ -0,0 +1,123 @@
|
||||
# Completions for phpenv command
|
||||
# Place in ~/.config/fish/completions/phpenv.fish
|
||||
|
||||
# Complete main commands
|
||||
complete -c phpenv -f -n "__fish_use_subcommand" -a "install" -d "Install a PHP version"
|
||||
complete -c phpenv -f -n "__fish_use_subcommand" -a "uninstall" -d "Uninstall a PHP version"
|
||||
complete -c phpenv -f -n "__fish_use_subcommand" -a "use" -d "Use PHP version for current shell"
|
||||
complete -c phpenv -f -n "__fish_use_subcommand" -a "local" -d "Set PHP version for current project"
|
||||
complete -c phpenv -f -n "__fish_use_subcommand" -a "global" -d "Set global PHP version"
|
||||
complete -c phpenv -f -n "__fish_use_subcommand" -a "list" -d "List installed PHP versions"
|
||||
complete -c phpenv -f -n "__fish_use_subcommand" -a "ls" -d "List installed PHP versions"
|
||||
complete -c phpenv -f -n "__fish_use_subcommand" -a "current" -d "Show current PHP version"
|
||||
complete -c phpenv -f -n "__fish_use_subcommand" -a "which" -d "Show path to PHP binary"
|
||||
complete -c phpenv -f -n "__fish_use_subcommand" -a "versions" -d "Show all available versions"
|
||||
complete -c phpenv -f -n "__fish_use_subcommand" -a "doctor" -d "Check phpenv installation"
|
||||
complete -c phpenv -f -n "__fish_use_subcommand" -a "config" -d "Manage configuration"
|
||||
complete -c phpenv -f -n "__fish_use_subcommand" -a "extensions" -d "Manage PHP extensions"
|
||||
complete -c phpenv -f -n "__fish_use_subcommand" -a "ext" -d "Manage PHP extensions"
|
||||
complete -c phpenv -f -n "__fish_use_subcommand" -a "help" -d "Show help"
|
||||
|
||||
# Helper functions for completions
|
||||
function __phpenv_complete_installed_versions
|
||||
phpenv list 2>/dev/null | sed 's/^[* ]*//'
|
||||
end
|
||||
|
||||
function __phpenv_complete_available_versions
|
||||
# Try to get dynamic versions first
|
||||
if command -q curl -a command -q jq; and functions -q __phpenv_parse_version_field
|
||||
echo "latest"
|
||||
echo "nightly"
|
||||
echo "5.x"
|
||||
echo "7.x"
|
||||
echo "8.x"
|
||||
__phpenv_parse_version_field "latest" "8.4"
|
||||
__phpenv_parse_version_field "nightly" "8.5"
|
||||
__phpenv_parse_version_field "5.x" "5.6"
|
||||
__phpenv_parse_version_field "7.x" "7.4"
|
||||
__phpenv_parse_version_field "8.x" "8.4"
|
||||
end
|
||||
|
||||
# Fallback to common versions
|
||||
printf "5.6\n7.0\n7.1\n7.2\n7.3\n7.4\n8.0\n8.1\n8.2\n8.3\n8.4\n8.5\n"
|
||||
end
|
||||
|
||||
function __phpenv_complete_config_keys
|
||||
printf "global-version\nauto-install\nauto-install-extensions\nauto-switch\ndefault-extensions\n"
|
||||
end
|
||||
|
||||
function __phpenv_complete_extensions
|
||||
printf "xdebug\nredis\nimagick\nmongodb\nmemcached\npcov\nast\ngrpc\n"
|
||||
printf "protobuf\nyaml\nzip\ncurl\ngd\nintl\nmbstring\nmysql\nopcache\npdo\nsockets\nxml\n"
|
||||
end
|
||||
|
||||
function __phpenv_complete_binaries
|
||||
printf "php\nphp-config\nphpize\ncomposer\npecl\npear\n"
|
||||
end
|
||||
|
||||
# Complete versions for install command
|
||||
complete -c phpenv -f -n "__fish_seen_subcommand_from install" \
|
||||
-a "(__phpenv_complete_available_versions)" -d "PHP version"
|
||||
|
||||
# Complete installed versions for uninstall, use commands
|
||||
complete -c phpenv -f -n "__fish_seen_subcommand_from uninstall use local global" \
|
||||
-a "(__phpenv_complete_installed_versions)" -d "Installed PHP version"
|
||||
|
||||
# Add system option for use command
|
||||
complete -c phpenv -f -n "__fish_seen_subcommand_from use" -a "system" -d "Use system PHP"
|
||||
|
||||
# Complete binaries for which command
|
||||
complete -c phpenv -f -n "__fish_seen_subcommand_from which" -a "(__phpenv_complete_binaries)" -d "PHP binary"
|
||||
|
||||
# Complete config subcommands
|
||||
complete -c phpenv -f -n "__fish_seen_subcommand_from config; and not __fish_seen_subcommand_from get set list" \
|
||||
-a "get" -d "Get configuration value"
|
||||
complete -c phpenv -f -n "__fish_seen_subcommand_from config; and not __fish_seen_subcommand_from get set list" \
|
||||
-a "set" -d "Set configuration value"
|
||||
complete -c phpenv -f -n "__fish_seen_subcommand_from config; and not __fish_seen_subcommand_from get set list" \
|
||||
-a "list" -d "List all configuration"
|
||||
|
||||
# Complete config keys
|
||||
complete -c phpenv -f -n "__fish_seen_subcommand_from config; and __fish_seen_subcommand_from get set" \
|
||||
-a "(__phpenv_complete_config_keys)" -d "Configuration key"
|
||||
|
||||
# Complete config values for boolean settings
|
||||
complete -c phpenv -f \
|
||||
-n "__fish_seen_subcommand_from config; and __fish_seen_subcommand_from set" \
|
||||
-n "contains -- (commandline -opc)[-1] auto-install auto-install-extensions auto-switch" \
|
||||
-a "true false" -d "Boolean value"
|
||||
|
||||
# Complete extensions subcommands
|
||||
complete -c phpenv -f \
|
||||
-n "__fish_seen_subcommand_from extensions ext" \
|
||||
-n "not __fish_seen_subcommand_from install uninstall remove list ls available" \
|
||||
-a "install" -d "Install PHP extension"
|
||||
complete -c phpenv -f \
|
||||
-n "__fish_seen_subcommand_from extensions ext" \
|
||||
-n "not __fish_seen_subcommand_from install uninstall remove list ls available" \
|
||||
-a "uninstall" -d "Uninstall PHP extension"
|
||||
complete -c phpenv -f \
|
||||
-n "__fish_seen_subcommand_from extensions ext" \
|
||||
-n "not __fish_seen_subcommand_from install uninstall remove list ls available" \
|
||||
-a "remove" -d "Remove PHP extension"
|
||||
complete -c phpenv -f \
|
||||
-n "__fish_seen_subcommand_from extensions ext" \
|
||||
-n "not __fish_seen_subcommand_from install uninstall remove list ls available" \
|
||||
-a "list" -d "List installed extensions"
|
||||
complete -c phpenv -f \
|
||||
-n "__fish_seen_subcommand_from extensions ext" \
|
||||
-n "not __fish_seen_subcommand_from install uninstall remove list ls available" \
|
||||
-a "ls" -d "List installed extensions"
|
||||
complete -c phpenv -f \
|
||||
-n "__fish_seen_subcommand_from extensions ext" \
|
||||
-n "not __fish_seen_subcommand_from install uninstall remove list ls available" \
|
||||
-a "available" -d "Show available extensions"
|
||||
|
||||
# Complete extension names
|
||||
complete -c phpenv -f \
|
||||
-n "__fish_seen_subcommand_from extensions ext; and __fish_seen_subcommand_from install" \
|
||||
-a "(__phpenv_complete_extensions)" -d "PHP extension"
|
||||
|
||||
# Complete help options
|
||||
complete -c phpenv -f -s h -l help -d "Show help"
|
||||
|
||||
38
config/fish/conf.d/phpenv.fish
Normal file
38
config/fish/conf.d/phpenv.fish
Normal file
@@ -0,0 +1,38 @@
|
||||
# phpenv configuration file
|
||||
# Place in ~/.config/fish/conf.d/phpenv.fish
|
||||
|
||||
# Set default configuration using session variables for most settings
|
||||
# Only PHPENV_GLOBAL_VERSION needs to persist across shells
|
||||
if not set -q PHPENV_AUTO_INSTALL
|
||||
set -g PHPENV_AUTO_INSTALL false
|
||||
end
|
||||
|
||||
if not set -q PHPENV_AUTO_INSTALL_EXTENSIONS
|
||||
set -g PHPENV_AUTO_INSTALL_EXTENSIONS false
|
||||
end
|
||||
|
||||
if not set -q PHPENV_AUTO_SWITCH
|
||||
set -g PHPENV_AUTO_SWITCH true
|
||||
end
|
||||
|
||||
if not set -q PHPENV_DEFAULT_EXTENSIONS
|
||||
set -g PHPENV_DEFAULT_EXTENSIONS "opcache"
|
||||
end
|
||||
|
||||
# Initialize PATH on shell startup if global version is set (less aggressive)
|
||||
if test -n "$PHPENV_GLOBAL_VERSION"; and not set -q PHPENV_INITIALIZED
|
||||
if functions -q __phpenv_is_version_installed __phpenv_set_php_path
|
||||
if __phpenv_is_version_installed "$PHPENV_GLOBAL_VERSION" 2>/dev/null
|
||||
# Only set PATH if no project-specific version is detected
|
||||
if not __phpenv_find_version_file .php-version >/dev/null 2>&1
|
||||
if not __phpenv_find_version_file .tool-version >/dev/null 2>&1
|
||||
if not test -f composer.json
|
||||
__phpenv_set_php_path "$PHPENV_GLOBAL_VERSION" 2>/dev/null
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
set -g PHPENV_INITIALIZED true
|
||||
end
|
||||
|
||||
@@ -9,3 +9,4 @@ meaningful-ooo/sponge
|
||||
nickeb96/puffer-fish
|
||||
jgusta/paths
|
||||
patrickf1/fzf.fish
|
||||
ivuorinen/phpenv.fish
|
||||
|
||||
1078
config/fish/functions/phpenv.fish
Normal file
1078
config/fish/functions/phpenv.fish
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user