home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: OtherApp / OtherApp.zip / 4os225b.zip / ALIASES < prev    next >
Text File  |  1994-10-12  |  10KB  |  247 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. :             ff:     Uses the 4OS2 FFIND command to find a file anywhere
  111. :                     in the current directory or any of its subdirectories,
  112. :                     for example:
  113. :
  114. :                             ff *.dat
  115. :
  116. :             fft:    Like FF, but assumes that the second and following
  117. :                     arguments are text to look for within the files.  For
  118. :                     example, to find all .DAT files with the string "hello
  119. :                     Barbara" in them you could use this command:
  120. :
  121. :                             fft *.dat hello barbara
  122. :
  123. :             sdel:   Allows you to select files for deletion from a subset
  124. :                     of files as specified in the command argument.  For
  125. :                     example:
  126. :
  127. :                             sdel *.obj
  128. :
  129. :                     will allow you to select files to delete from a list
  130. :                     of all .obj files.  (See the SELECT command in the
  131. :                     manual for more details).
  132. :
  133. :             up:     Moves "up" in the directory tree, i.e. to the parent
  134. :                     directory.
  135. :
  136. :             ov:     Moves "over" in the directory tree, to another subdi-
  137. :                     rectory which has the same parent as the current
  138. :                     directory.
  139. :
  140. mo*re list /s
  141. ff ffind /s
  142. fft ffind /s /t"%2$" %1 
  143. sdel select del (%1)
  144. up cd ..
  145. ov cd ..\%1
  146. :
  147. :     The next two aliases show how arguments can be passed to commands.
  148. :     In both cases the argument given when the alias is invoked is passed
  149. :     to the program at the appropriate place in its command string.
  150. :
  151. :
  152. lp lpr -u %1 >lpt1
  153. ps d:\peri\ps /t:%1 /e:4
  154. :
  155. :     The next few aliases demonstrate several things.  Some use the
  156. :     command separator character & to include multiple commands in
  157. :     the alias.  ND2 uses the "&&" (AND) operator so that the second
  158. :     command is only executed if the first was succcessful.  The last
  159. :     two (PC and BACK) use the alias called IN to do their job.  In
  160. :     fact IN was designed for "internal" use by other aliases in this
  161. :     file, though it could be used elsewhere as well.  Note that, while
  162. :     PX is set up before it is referenced in other aliases, this is not
  163. :     really necessary, because any command in one alias which refers to
  164. :     another is handled when the alias is invoked, not when it is set
  165. :     up with the alias command.
  166. :
  167. :     Here's what each alias does:
  168. :
  169. :             nd:     Creates a new directory below the current directory,
  170. :                     then changes to it.
  171. :
  172. :             nd2:    Attempts to creates the specified directory on any
  173. :                     drive, then changes to it if the creation was
  174. :                     successful.
  175. :
  176. :             w:      Saves the current directory, changes to the ws
  177. :                     directory on drive c:, runs the ws program using
  178. :                     the first argument on the command line, and
  179. :                     restores the original directory when done.
  180. :
  181. :             zap:    Deletes all the .bak files in the current directory,
  182. :                     then does a wide directory listing.
  183. :
  184. :             in:     "Pushes" a different directory, executes a command,
  185. :                     including all of the arguments on the command line,
  186. :                     and then goes back to the original directory.  See
  187. :                     PUSHD, POPD, and Alias Parameters in the manual for
  188. :                     more details.
  189. :
  190. :             pc:     Changes to the \comm directory on drive c:, runs
  191. :                     the program called pcomm, then returns to the
  192. :                     drive and directory in use when the command was
  193. :                     executed.
  194. :
  195. :             back:   Changes to the \backup directory on drive d:, runs
  196. :                     the program called tape, then returns to the previous
  197. :                     drive and directory.
  198. :
  199. nd md %1 & cd %1
  200. nd2 md %1 && *cdd %1
  201. w pushd c:\wp & ws %1 & popd
  202. zap del *.bak & dir /w
  203. in pushd %1 & %2$ & popd
  204. pc in c:\comm pcomm
  205. back in d:\backup tape
  206. :
  207. :     The following aliases make use of the %$ argument.  This argument
  208. :     means "all of the arguments on the command line".  For example:
  209. :
  210. :             zap2 *.bak *.lst *.bk!
  211. :
  212. :     expands to:
  213. :
  214. :             erase *.bak *.lst *.bk! & chkdsk & dir /w
  215. :
  216. :     The last of the three aliases below uses the %@eval function to
  217. :     create a command-line calculator, by simply passing all arguments
  218. :     on the command line to the function.
  219. :
  220. zap2 erase %$ & chkdsk & dir /w
  221. ed edit %$ & del *.bak
  222. cal*c echo The answer is:  %@eval[%$]
  223. :
  224. :
  225. :     The following aliases show the use of IFF in aliases.  The first
  226. :     redefines SET so that it displays the environment variables with a
  227. :     /P if no parameters are given, or processes the SET if parameters
  228. :     are specified.  The second checks whether the argument is a directory;
  229. :     if so it deletes the files in the directory and then removes the
  230. :     directory.  If not, it gives an error message.
  231. :
  232. set iff "%1"=="" then & *set /p & else *set %$ & endiff
  233. zap iff isdir %1 then & *del %1 & *rd %1 & else & beep & echo Not a directory! & endiff
  234. :
  235. :     You can also assign any alias to a keystroke to save a lot of typing.
  236. :     Check your manual for the proper way to express keynames.
  237. :
  238. :     The following examples reassign the following keys:
  239. :
  240. :        F5:        wide directory
  241. :           Ctrl-F1    clear screen
  242. :           Alt-F4:    exit the session
  243. :
  244. @@f5 dir /w
  245. @@Ctrl-F1 cls
  246. @@alt-f4 exit
  247.