home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / os2 / 4os2b.zip / ALIASES < prev    next >
Text File  |  1993-12-16  |  9KB  |  232 lines

  1. :
  2. :                     ALIASES -- 4OS2 Sample Alias File
  3. :
  4. :
  5. :     The aliases in this file are designed to give you some examples of
  6. :     how 4OS2 aliases can be used and the power they have.  It is not
  7. :     intended to be an exhaustive list, and many of these may not be
  8. :     appropriate for your needs.  But they should give you a feel for how
  9. :     to use aliases to help get your work done.
  10. :
  11. :     CAUTION:  These aliases are EXAMPLES.  We do NOT promise that they
  12. :     will work properly when run on your system.  They are simply intended
  13. :     to show what's possible and give you a feel for how to write your
  14. :     own set of aliases.  You may find some of them useful, but others
  15. :     may fail or have unintended effects when they are run on a system
  16. :     other than the one they were designed for.
  17. :
  18. :     This file is designed to be loaded with an ALIAS /R command, for
  19. :     example:
  20. :
  21. :               alias /r aliases
  22. :
  23. :     You can also load aliases from a batch file, but ALIAS /R is much
  24. :     faster.  See the manual for more details on loading aliases.
  25. :
  26. :     We suggest you put your standard aliases are in a self-contained
  27. :     file like this one which can be invoked from 4START.  That way the
  28. :     file can also be re-invoked after it is edited, to re-install the
  29. :     aliases.  (For more information on loading aliases from your
  30. :     4START or STARTUP.CMD file, see your reference manual).
  31. :
  32. :
  33. :
  34. :     The next few aliases set up some directory commands that provide
  35. :     shorthand ways to view the directory in several different formats
  36. :     (see the DIR command in the manual for more details).
  37. :
  38. :     Note that none of these aliases has any arguments specified (%1,
  39. :     %2, etc.).  This means that all arguments on the actual command line
  40. :     will be appended to the alias text.  For example:
  41. :
  42. :             d2 x*
  43. :
  44. :     is equivalent to:
  45. :
  46. :             dir /2pv x*
  47. :
  48. :     and:
  49. :
  50. :             d2 x* y* z*
  51. :
  52. :     is equivalent to:
  53. :
  54. :             dir /2pv x* y* z*
  55. :
  56. d2 dir /2pv
  57. de dir /oe
  58. dir *dir /p
  59. wh*ereis dir /dp
  60. :
  61. :     The last two commands above demonstrate the use of an asterisk to
  62. :     terminate alias expansion and to shorten the name of an alias.
  63. :
  64. :     In the first case, if the command were defined as:
  65. :
  66. :             alias dir dir/p
  67. :
  68. :     it would generate an alias loop error.  The inclusion of the "*"
  69. :     makes 4OS2 terminate alias expansion for that command, which
  70. :     allows the redefinition of a command with specific switch settings.
  71. :     In this case "dir" is redefined as "dir/p", which will cause
  72. :     directories to be displayed with a pause at the end of each page.
  73. :
  74. :     The "whereis" command demonstrates truncation of an alias name.
  75. :     The * is placed after the last required character in the name, so
  76. :     the "whereis" command can be entered as "wh", "whe", "wher",
  77. :     "where", "wherei", or "whereis".
  78. :
  79. :
  80. :     The following aliases are more shorthand:  DD and DU (directory
  81. :     down and directory up) for pushd and popd, DX (shows only the
  82. :     subdirectories, L for list, etc.
  83. :
  84. dd pushd
  85. du popd
  86. dx *dir /mwad
  87. l list
  88. clr mode mono
  89. :
  90. :     Aliases can also be used to modify the behavior of some internal
  91. :     commands.  The two examples below show how you can force DELETE and
  92. :     MOVE to prompt before execution.  If you need to use the unprompted
  93. :     command, use the leading asterisk ("*DEL").
  94. del*ete *del /p
  95. move *move /r
  96. :
  97. :
  98. :     The next aliases show how some commands can be enhanced.  Instead of
  99. :     always prompting you for new values, TIME and DATE can simply report
  100. :     the current information.
  101. :
  102. date echo Today is %_dow %_date
  103. time echo The time is %_time
  104. :     Here's what the next few aliases do:
  105. :
  106. :             more:   Uses 4OS2's LIST /S as a substitute for the MORE
  107. :                     command.  Note the use of the * to allow the command
  108. :                     to be entered as MO, MOR, or MORE
  109. :
  110. :             sdel:   Allows you to select files for deletion from a subset
  111. :                     of files as specified in the command argument.  For
  112. :                     example:
  113. :
  114. :                             sdel *.obj
  115. :
  116. :                     will allow you to select files to delete from a list
  117. :                     of all .obj files.  (See the SELECT command in the
  118. :                     manual for more details).
  119. :
  120. :             up:     Moves "up" in the directory tree, i.e. to the parent
  121. :                     directory.
  122. :
  123. :             ov:     Moves "over" in the directory tree, to another subdi-
  124. :                     rectory which has the same parent as the current
  125. :                     directory.
  126. :
  127. mo*re list /s
  128. sdel select del (%1)
  129. up cd ..
  130. ov cd ..\%1
  131. :
  132. :     The next two aliases show how arguments can be passed to commands.
  133. :     In both cases the argument given when the alias is invoked is passed
  134. :     to the program at the appropriate place in its command string.
  135. :
  136. :
  137. lp lpr -u %1 >lpt1
  138. ps d:\peri\ps /t:%1 /e:4
  139. :
  140. :     The next few aliases demonstrate several things.  Some use the
  141. :     command separator character & to include multiple commands in
  142. :     the alias.  ND2 uses the "&&" (AND) operator so that the second
  143. :     command is only executed if the first was succcessful.  The last
  144. :     two (PC and BACK) use the alias called IN to do their job.  In
  145. :     fact IN was designed for "internal" use by other aliases in this
  146. :     file, though it could be used elsewhere as well.  Note that, while
  147. :     PX is set up before it is referenced in other aliases, this is not
  148. :     really necessary, because any command in one alias which refers to
  149. :     another is handled when the alias is invoked, not when it is set
  150. :     up with the alias command.
  151. :
  152. :     Here's what each alias does:
  153. :
  154. :             nd:     Creates a new directory below the current directory,
  155. :                     then changes to it.
  156. :
  157. :             nd2:    Attempts to creates the specified directory on any
  158. :                     drive, then changes to it if the creation was
  159. :                     successful.
  160. :
  161. :             w:      Saves the current directory, changes to the ws
  162. :                     directory on drive c:, runs the ws program using
  163. :                     the first argument on the command line, and
  164. :                     restores the original directory when done.
  165. :
  166. :             zap:    Deletes all the .bak files in the current directory,
  167. :                     then does a wide directory listing.
  168. :
  169. :             in:     "Pushes" a different directory, executes a command,
  170. :                     including all of the arguments on the command line,
  171. :                     and then goes back to the original directory.  See
  172. :                     PUSHD, POPD, and Alias Parameters in the manual for
  173. :                     more details.
  174. :
  175. :             pc:     Changes to the \comm directory on drive c:, runs
  176. :                     the program called pcomm, then returns to the
  177. :                     drive and directory in use when the command was
  178. :                     executed.
  179. :
  180. :             back:   Changes to the \backup directory on drive d:, runs
  181. :                     the program called tape, then returns to the previous
  182. :                     drive and directory.
  183. :
  184. nd md %1 & cd %1
  185. nd2 md %1 && *cdd %1
  186. w pushd c:\wp & ws %1 & popd
  187. zap del *.bak & dir /w
  188. in pushd %1 & %2$ & popd
  189. pc in c:\comm pcomm
  190. back in d:\backup tape
  191. :
  192. :     The following aliases make use of the %$ argument.  This argument
  193. :     means "all of the arguments on the command line".  For example:
  194. :
  195. :             zap2 *.bak *.lst *.bk!
  196. :
  197. :     expands to:
  198. :
  199. :             erase *.bak *.lst *.bk! & chkdsk & dir /w
  200. :
  201. :     The last of the three aliases below uses the %@eval function to
  202. :     create a command-line calculator, by simply passing all arguments
  203. :     on the command line to the function.
  204. :
  205. zap2 erase %$ & chkdsk & dir /w
  206. ed edit %$ & del *.bak
  207. cal*c echo The answer is:  %@eval[%$]
  208. :
  209. :
  210. :     The following aliases show the use of IFF in aliases.  The first
  211. :     redefines SET so that it displays the environment variables with a
  212. :     /P if no parameters are given, or processes the SET if parameters
  213. :     are specified.  The second checks whether the argument is a directory;
  214. :     if so it deletes the files in the directory and then removes the
  215. :     directory.  If not, it gives an error message.
  216. :
  217. set iff "%1"=="" then & *set /p & else *set %$ & endiff
  218. zap iff isdir %1 then & *del %1 & *rd %1 & else & beep & echo Not a directory! & endiff
  219. :
  220. :     You can also assign any alias to a keystroke to save a lot of typing.
  221. :     Check your manual for the proper way to express keynames.
  222. :
  223. :     The following examples reassign the following keys:
  224. :
  225. :        F5:        wide directory
  226. :           Ctrl-F1    clear screen
  227. :           Alt-F4:    exit the session
  228. :
  229. @@f5 dir /w
  230. @@Ctrl-F1 cls
  231. @@alt-f4 exit
  232.