<HTML> <HEAD><TITLE>Using DOSKEY Macros</TITLE></HEAD> <H1>Using DOSKEY Macros</H1><HR> <H2>Overview</H2> <P>You can setup DOSKEY Macros to speed up your command line activity even more. Macros save typing, and allow you to combine multiple commands into one. They are a light weight alternative to batch files, and they perform faster.</P> <P>To use macros:</P> <OL> <LI>Create macros and store them in a file. <LI>Create/modfiy a Command Prompt shortcut so it references your macros file. </OL> <HR> <H2>Creating DOSKEY Macros</H2> <P><A HREF="http://www.microsoft.com/windowsxp/home/using/productdoc/en/default.asp?url=/windowsxp/home/using/productdoc/en/doskey.asp">Click here</A> for extensive Microsoft macro documentation and examples.</P> <P>Example: Create a DOSKEY macro named <B>ue</B> that syncs a file, open it for edit in Perforce, and then opens it in a favorite editor:</P> <PRE> doskey ue=p4 sync $* $T p4 edit $* $T "D:\Program Files\UltraEdit\uedit32.exe" $* </PRE> <P>The <C>$T</C> is a separator, used when you combine several commands in one. Use $1 for the 1st argument, $2 for the second, etc., or $* for all arguments.</P> <H2>Store your macros in a file (doskey.mac)</H2> <P>Create a series of such macros, and put them in a file. Store your macros anwyere you like; they usually go in a file named doskey.mac. If you would like to put your macros in version control, create a folder under //depot/admin/users/<I>youruserid</I> in Perforce. For example, you might create your doskey.mac file as: <PRE> D:\p4\Projects.<I>userid</I>\depot\admin\users\<I>userid</I>\doskey.mac </PRE> <P>Then just add it to Perforce and change it like any other versioned file.</P> <P>Then create a shortcut (or modify the existing shortcut in the Start Menu) so it looks something like this:</P> <PRE> %windir%\System32\CMD.exe /F:ON /K DOSKEY /macrofile="D:\p4\Projects.<I>userid</I>\depot\admin\users\<I>userid</I>\doskey.mac" </PRE> <I>Note:</I> The <B><C>/F:ON</C></B> is <I>supposed</I> to enable command completion, but if you already have it enabled, it seems to have the opposite effect. If so, get rid of the <B><C>/F:ON</C></B> text.</P> <P>If you don't want to put your macros in version control, you might use the %USERPROFILE% variable to put them in your home directory:</P> <PRE> %windir%\System32\CMD.exe /F:ON /K DOSKEY /macrofile="%USERPROFILE%\doskey.mac" </PRE> <P>Advanced Topic: If you need your macros to be portable across machines (e.g. your desktop and laptop), you can define a system variable, say <B>UDIR</B>, and set it contain the path on your local machine where your doeskey.mac file lives. Then, use (or define if necessary) variables that show where programs used in macros (such as your favorite editors) are installed.</P> <HR> <H2>DOSKEY Documetation</H2> <P><A HREF="http://www.microsoft.com/windowsxp/home/using/productdoc/en/default.asp?url=/windowsxp/home/using/productdoc/en/doskey.asp">Click here</A> for extensive Microsoft macro documentation and examples.</P> <P>Just for quick reference, here's the DOS info for DOSKEY (Run '<C>DOSKEY /?</C>' from a command prompt to get this):</P> <PRE> Edits command lines, recalls Windows 2000 commands, and creates macros. DOSKEY [/REINSTALL] [/LISTSIZE=size] [/MACROS[:ALL | :exename]] [/HISTORY] [/INSERT | /OVERSTRIKE] [/EXENAME=exename] [/MACROFILE=filename] [macroname=[text]] /REINSTALL Installs a new copy of Doskey. /LISTSIZE=size Sets size of command history buffer. /MACROS Displays all Doskey macros. /MACROS:ALL Displays all Doskey macros for all executables which have Doskey macros. /MACROS:exename Displays all Doskey macros for the given executable. /HISTORY Displays all commands stored in memory. /INSERT Specifies that new text you type is inserted in old text. /OVERSTRIKE Specifies that new text overwrites old text. /EXENAME=exename Specifies the executable. /MACROFILE=filename Specifies a file of macros to install. macroname Specifies a name for a macro you create. text Specifies commands you want to record. UP and DOWN ARROWS recall commands; ESC clears command line; F7 displays command history; ALT+F7 clears command history; F8 searches command history; F9 selects a command by number; ALT+F10 clears macro definitions. The following are some special codes in Doskey macro definitions: $T Command separator. Allows multiple commands in a macro. $1-$9 Batch parameters. Equivalent to %1-%9 in batch programs. $* Symbol replaced by everything following macro name on command line. </PRE> <HR><H2>Sample DOSKEY.MAC File</H2> <P>For this example, the <B>UDIR</B>, <B>ULTRAEDITHOME</B>, and <B>EMACSHOME</B> system variables were defined.</P> <PRE> savemac=doskey /macros > "%UDIR%\doskey.mac" omac=p4 sync "%UDIR%\doskey.mac" $T p4 edit "%UDIR%\doskey.mac" $T "%ULTRAEDITHOME%\uedit32.exe" "%UDIR%\doskey.mac" loadmac=doskey /macrofile="%UDIR%\doskey.mac" $T echo Loaded macros from doskey.mac mac=doskey /macros $* listmac=doskey /macros $* n=notepad $1 get=p4 sync $* cue=p4 sync $* $T p4 edit $* $T "%ULTRAEDITHOME%\uedit32.exe" $* e="%EMACSHOME%\bin\runemacs.exe" $* ue="%ULTRAEDITHOME%\uedit32.exe" $* ci=p4 submit $1 co=p4 sync $* $T p4 edit $* lshist=p4 filelog -i $* lsh=p4 filelog $* sync=p4 sync $* showmac=doskey /macros $* openmac=p4 sync "%UDIR%\doskey.mac" $T p4 edit "%UDIR%\doskey.mac" $T "%ULTRAEDITHOME%\uedit32.exe" "%UDIR%\doskey.mac" </PRE> <P><I>Last updated Fri, 20 Aug 2004, 18:54:40 ET</I></P> </BODY> </HTML>
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 30968 | C. Thomas Tyler |
Migration from Classic to Streams with: p4 copy -b P4BBI_Classic_to_Streams |
||
//guest/perforce_software/p4bbi/main/test/baselines/FGS-1.1.p2-to-MAIN-MergeResult/docs/FAQ/UsingDOSKEYMacros.htm | |||||
#1 | 9147 | C. Thomas Tyler | Added inital version of P4BBI to The Perforce Workshop. |