diff --git a/fish/.config/fish/conf.d/abbr.fish b/fish/.config/fish/conf.d/abbr.fish index d8a8c0d..272c91f 100644 --- a/fish/.config/fish/conf.d/abbr.fish +++ b/fish/.config/fish/conf.d/abbr.fish @@ -19,3 +19,8 @@ abbr -a gp git push if type -q "lazygit" abbr -a lg lazygit end + +# doctrine +abbr -a scme sc make:entity +abbr -a scmm sc make:migration +abbr -a scdm sc doctrine:migrations:migrate diff --git a/fish/.config/fish/functions/sc.fish b/fish/.config/fish/functions/sc.fish new file mode 100644 index 0000000..ad6f69f --- /dev/null +++ b/fish/.config/fish/functions/sc.fish @@ -0,0 +1,29 @@ +function sc + # Step 1: Extract PHP version constraint from composer.json + set constraint (jq -r '.require.php // empty' composer.json | grep -oP '\d+\.\d+') + + if test -z "$constraint" + echo "No PHP version constraint found in composer.json" + return 1 + end + + # Step 2: Find matching PHP binaries using find + set match "" + for bin in (find /usr/bin -maxdepth 1 -type f -executable -regex '.*/php[0-9]+\.[0-9]+') + set version_output ($bin -v 2>/dev/null | head -n 1) + set php_version (echo $version_output | grep -oP '\d+\.\d+') + + if test "$php_version" = "$constraint" + set match $bin + break + end + end + + if test -z "$match" + echo "No installed PHP binary matches constraint $constraint" + return 1 + end + + # Step 3: Execute Symfony console with matched PHP binary + $match ./bin/console $argv +end \ No newline at end of file