Add symfony abbreviations
This commit is contained in:
parent
3405ca7784
commit
c2c4b4755c
@ -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
|
||||
|
29
fish/.config/fish/functions/sc.fish
Normal file
29
fish/.config/fish/functions/sc.fish
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user