aliasme icon indicating copy to clipboard operation
aliasme copied to clipboard

Dynamic Commands

Open Dosx001 opened this issue 4 years ago • 9 comments

This change will allow aliasme.sh to run dynamic commands instead of just static commands. For example, when you create something like this "al add new 'cd'". Then when you run "al new root/directory" then it will change your directory to "../root/directory" or anything base on your input.

Dosx001 avatar Jan 03 '21 02:01 Dosx001

It's really cool feature that I also want to include for aliasme for a long time. Just some though to add on, can we indicate the dynamic part to place at anywhere we want of the command? Also is it possible to make support multiple dynamic part? Thanks for you contribute!!

Jintin avatar Jan 03 '21 03:01 Jintin

What do you mean anywhere? Do you mean something like this "al root/directory new"?

I think for multiple dynamic parts, to keep the code simple, we could have a keyword to start a multiple dynamic command. Something like this "al multi_dynamic alias input1 input2".

Dosx001 avatar Jan 03 '21 15:01 Dosx001

MD stands for multiple dynamic "al dynamic" is just "vim" image

Dosx001 avatar Jan 03 '21 17:01 Dosx001

Ya am getting a little crazy with this. When you call WordCount the "?" is replaced by whatever put as an argument on the command line. image With a little work, I can make a combination of both the Multiple Dynamic and Fill

Dosx001 avatar Jan 03 '21 21:01 Dosx001

This one is pretty cool. Oh ya, I changed "Fill" to just "F" and "MF" stands for Multiple Fill. image

Dosx001 avatar Jan 03 '21 22:01 Dosx001

What do you mean anywhere? Do you mean something like this "al root/directory new"?

I think for multiple dynamic parts, to keep the code simple, we could have a keyword to start a multiple dynamic command. Something like this "al multi_dynamic alias input1 input2".

Ya, similar to what you say, put a symbol to indicate the dynamic part. Don't know why I don't get notify about the following chat, you can pin my id next time.

Jintin avatar Jan 04 '21 11:01 Jintin

@Jintin """Some suggest on the dynamic or multi-fill part. Is is possible to put some indicator like $1 $2 indicate multiple usage? or $0 for list type of data? example: mv $1.md $1.txt vim $0"""

I did use $1, $2, etc before. But you would need to backlash it when adding a new alias. Something like this "al add new '\$1 \$2 \$3' FM". I didn't like having to type an extra character so I changed "$" to "?".

Dosx001 avatar Jan 04 '21 22:01 Dosx001

@Jintin Check out these new changes!!! This pull request just keeping getting crazier lol.

First off, the biggest change is now Fills and Multi Fills are now the same thing just Fills. While the new Multi Fills is now a combination of Fill and Dynamic.

Here is a visual example. image

When you “al ls”, you’ll see that Multi Fills have a number next to them, this number is the amount of arguments needed to run the alias command. In order to add a Multi Fill alias you need to do something like this “al add VP ‘vim ?1 ?2 ?3 ?4 -p’ MF 4”. Then just run like this “al VP a.py b.py c.py d.py”

You can also have something like this. image

Dosx001 avatar Jan 04 '21 22:01 Dosx001

Fills can now take as many arguments as possible like this

image

I also changed how you declare the cmdType when adding a new alias. I kept typing "FM" instead of "MF", so this change will greatly help me lol, and overall less typing. D -> d F -> f MF -> m

Dosx001 avatar Jan 05 '21 00:01 Dosx001