Reputation: 133
I have created an alias to open an older git version of a file in sublime text.
My alias accepts 2 arguments, $1 is the revision and $2 is the file path, but I would like to parse the arguments to get the file extension of the file to open it in its correct format.
My existing code is here:
revise=git show $1:$2 > redirected.txt $T C:/PROGRA~1/SUBLIM~2/sublime_text.exe redirected.txt
However I would like to to something like:
revise=git show $1:$2 > redirected.{$2.extesnion} $T C:/PROGRA~1/SUBLIM~2/sublime_text.exe redirected.{$2.extesnion}
Upvotes: 1
Views: 1476
Reputation: 11
environment details:
in cmd.exe session you can read parameters from the command line using the $* placeholder to get everything that comes after the alias, alias example:
vi=vim $*
alias usage:
D:\
λ vi test.txt
Or you can read space-delimited argument using placeholders $1, $2, $n... alias example:
example= echo param one: $1 param two: $2
alias usage:
D:\
λ example hi how are you?
alias result:
param one: hi param two: how
note -are- and -you?- where no echoed
Upvotes: 1