I want to open a file in cmd
and edit it in Sublime Text's specific group, so I create a doskey like this
rem version 1, ^&
doskey st="path_to\Sublime Text 3\sublime_text" --command "focus_group { \"group\": $1 }" ^& "path_to\Sublime Text 3\sublime_text" $2
rem version 2, $T
doskey st="path_to\Sublime Text 3\sublime_text" --command "focus_group { \"group\": $1 }" $T "path_to\Sublime Text 3\sublime_text" $2
The command before ^&
or $T
will focus ST on group $1
you want, command after ^&
or $T
will open the file $2
Then in cmd
>>> rem version 1, ^&
>>> st 0 test.py & rem press enter
>>>
----------------------------------
>>> rem version 2, $T
>>> st 0 test.py & rem press enter, one more prompt compare version 1
>>>
>>>
Another try
rem alias.bat in C:\Windows\System32, work like alias in linux
doskey lscd1=dir ^& cd ..
doskey lscd2=dir $T cd ..
Result
path1\path2> lscd1
Volume in drive C is OS
Volume Serial Number is DA7D-663C
Directory of path2
11/24/2019 09:45 PM 0 test.py
path1>
---------------------------------
path1\path2> lscd2
Volume in drive C is OS
Volume Serial Number is DA7D-663C
Directory of path2
11/24/2019 09:45 PM 0 test.py
path1\path2>
path1>
The Doc of $T
is
$T or $t Separates commands. Use either of these special characters to separate commands when you create macros or type commands on the doskey command line. These special characters are equivalent to using the ampersand (&) on a command line.
I guess ^&
is 'escape the ampersand', why these two behave differently?