I need to set up a function in zsh that would edit a different file based on some input at the command line.
I want to simplify my aliases so I don't have multiple aliases to do the same thing but with a slight variation. I am specifically trying to set up a function to open in my editor different versions of the php.ini file (for php 5.4, 5.5, 5.6 and 7.0)
Right now, I have defined the following aliases:
alias editphpini54="subl /usr/local/etc/php/5.4/php.ini" alias editphpini55="subl /usr/local/etc/php/5.5/php.ini" alias editphpini56="subl /usr/local/etc/php/5.6/php.ini" alias editphpini70="subl /usr/local/etc/php/7.0/php.ini"
What I would like to do is set up a function called
editphpini and then input a variable (version number) and have it intelligently open up the right file. This could then be future-proof as well, as long as the basic path remains the same.
So, what I want to do be able to type in
And have the function parse that command and load the
php.ini file located in
Using the above example, I would then be able to substitute
70 at the end of the command and that would issue the relevant command.
In my thoughts, the function would take the
XX version number, insert it into the command
subl /usr/local/etc/php/X.X/php.ini using the
XX to define the version number.
Honestly, I have tried multiple things, and nothing seems to work, so rather than just list all my failed attempts, I'd appreciate if someone could point me in the right direction.