Short: CD replacement (wildcards, history) Author: soenke@kino-fahrplan.de (Sönke Tesch) Uploader: soenke@kino-fahrplan.de Type: util/cli Keywords: CD Modula-2 History Interface: Shell CLI HistoryCD is a replacement for the original CD shell command. Several years ago I thought that it would be nice to have the name of the current directory in the title of the CLI window. I therefore wrote a replacement for the original cd called TitleCD, which is also available from Aminet as util/cli/TitleCD.lha. The whole thing has been extended with wildcard support, an argument that speeds up changing between the current and the last directory ("cd lastdir" instead of "cd sys:bla/blo/ble/bli") and writing/reading the directory to or from a file. In the latest release, TitleCD has been extended with history functions. HistoryCD is actually TitleCD without the Title in it. So if your shell already displays the name of the current directory in the window title or are happy with the way C='s shell does it, HistoryCD is for you. Installation ============ Only three steps to heaven: a) 'copy HistoryCD to c:cd' Due to limitations of the Shell commands set and get (see "Environment variables" below) you should also 'copy get to c:' b) Add the lines resident cd remove resident get remove to your s:user-startup to disable the build-in commands CD and get of the shell. c) Reboot, or execute the lines from b) manually. That`s it :) If you want to you can make HistoryCD resident but this is not necessary unless you`re using a floppy-disc-based system. You will not notice any speed difference with harddisks. How to use ========== HistoryCD DIR,TO/K,FROM/K,LASTDIR/S,NEXT/S,PREV/S,FIRST/S,LAST/S DIR New current directory - same as in the original but TitleCD also supports wildcards e.g. "cd sys:#?/pri#?" will most likely cd to "sys:devs/printers" (unless "sys:letters/private" appears first). TitleCD chooses the first directory that matches your pattern. If this is not the needed one simply be a bit more precise next try. TO/K If this appears in the arguments TitleCD writes the name of the current directory to this file. No newline is appended! FROM/K If this appears in the arguments TitleCD reads the name of the new current directory from this file. LASTDIR/S If set TitleCD switches back to the last directory you have been to. Example: 1.ram:env/system/EggPaint> cd sys:graphics/EggPaint 1.sys:graphics/EggPaint> cd lastdir 1.ram:env/system/EggPaint> NEXT/S,PREV/S Move to the next or previous directory in the history buffer. See below for detailed instructions. FIRST/S,LAST/S Move to the first or last directory in the history buffer. See below for detailed instructions. The options TO and especially FROM might not be very useful at first, however they will come handy to move back to the original directory after executing some script, for example. Directory History ----------------- HistoryCD keeps track of all directories your have visited using a FIFO (first in, first out) buffer of 1024 bytes. You can check parts of the contents of this buffer with the Shells' set command (Shell's get will -not- work, use the get included in this archive instead), just have a look at local environment variable DirHistory: 5> set CurrentDir Ram Disk: DirHistory 0 evoSonic:Spiele 1 evoSonic: > 2 Ram Disk: 3 evoSonic:sprachen/Cyclone/Programme/TitleCD LastDir evoSonic:Spiele The current directory is always marked with a ">" (number 2 in the example above). New directories move in on top of this list, so in our example, we have first been to entry 3, then 2, 1, 0 and now moved back in history to number 2. Note: Please also have a look at "Environment variables" below. To use the history functions it`s important to know that the newest entry is on top of the list and the oldest at it`s end. The functions move in "time", i.e. to a directory visited later or earlier, not in "space", i.e. up and down in this list (although this seems to be the same if you had just a quick look). There are four arguments to control your movement in the history list, the list of recently visited directories: NEXT, PREV NEXT and PREV move forwards or backwards in the list. Moving forwards means moving forward in time, towards the top of the list, towards the newest entry in the list, to the next entry you visited from the current directory in the list. Previous means moving backward in time, towards the end of the list, towards the oldest entry, to the directory you visited prevously, before the current directory in the list. FIRST, LAST FIRST brings you to the first entry in the list, LAST to the last. The first entry is -not- the one on top of the list, but the one that has been added first to it, the oldest entry. The last entry is the latest one added, the one on top of the list. You may also move more than one step at a time: 5> HistoryCD next 2 brings us to the directory number 0 in the example above (we`re now in directory 2, the next one would be 1, the second next one is 0). This option of course also works with PREV, FIRST and LAST. The history feature does not interfere with LASTDIR. LASTDIR keeps working as it always did in TitleCD. This all seems to be a bit too complicated? Just give it a try, learning by doing is the still best way to figure something out :) Environment Variables ===================== HistoryCD sets/uses two local variables: LastDir - the name of the last current directory CurrentDir - the name of the current current directory DirHistory - the list of directories you`ve been in LastDir is actually used for the LASTDIR argument, DirHistory is the buffer for the history functions. You can use the shell commands set and get to access these (see AmigaDOS manual), however both of them have some limitations: - set shows only a small portion of the whole contents of a variable. After having traveled a while around your disks, you'll notice that set returns something like this: 1> set DirHistory 0 evoSonic:sprachen/Cyclone/modules/txt 1 evoSonic:sprachen/Cyclone/modules 2 evoSonic:sprachen/Cyclone/modules/txt > 3 evoSonic:sprachen/Cyclone/Programme/TitleCD 4 evoSonic: 5 Ram Disk: 6 evoSonic:sprachen/Cy 1> Only one half of entry 6 is displayed, and there might be more entries stored in the variable, but set doesn't display them. - get is even a bit worse, it only displays the first line of a variable. DirHistory from above would be displayed as follows: 1> get DirHistory 0 evoSonic:sprachen/Cyclone/modules/txt 1> To get around these limitations, copy the command get from this archive to c: and add 'resident get remove' to your user-startup. Copyright ========= HistoryCD, HistoryCD.readme, HistoryCD.doc and get: Copyright 1993-2000 by Sönke Tesch All Rights Reserved. You may re-distribute the archive as long as no file is removed or changed. HistoryCD has to be distributed for FREE, any other kind of distribution without my written permission is not allowed. However, this is not the case for any Aminet-CD. Others please feel free to ask. I do not give any guarantee for the quality and usefulness of this programm, nor that it works as described or fits particular needs. Contact ======= Comments, suggestions, questions, bug-reports and Hey-I-use-it!-mails are always welcome! Just write to . Those finer details.. ===================== HistoryCD is written using Cyclone Modula-2 by Marcel Timmermans. The source of HistoryCD is available on request, just ask. Also have a look at Find, a file finder for the shell. You can find Find at Aminet:util/cli/Find_v203.lha History ======= No history yet for HistoryCD, but here's some data for TitleCD: The first version was born sometime back in 1993, written using the DevPac assembler. After M2Amiga Modula-2 had been massively improved I used that language again. Version 3 was completely re-written using Cyclone Modula-2. Changes from 4.00 to 4.1: + Moving in the history buffer did not work correctly. First time was ok, but the next move removed all entries newer than the current one. This means you could actually just move backwards. Is this a case for Emmett Brown? + TitleCD now tries to get the real Shell window, instead of using the one that Intuition reports to be currently active. Cost me another ~180 bytes (which is the reason why I didn't implement this routine earlier). + The "broken contents" of the history variable DirHistory was not the fault of TitleCD but of set. See "Environment variables" above. Included fixed get command to solve this problem. Changes from 3 to 4: + History. + The routine that calculates the width of the shell window title now really does calculate. Earlier versions just did some "well, this might be something from here minus something from there", not taking into account the windows' gadgets and probably also using the wrong font. + If the FROM-file contained newlines this option would not work since the length calculation was somehow broken. Unfortunatly even if fixed FROM would not work with files that contain more than one line. Completely re-written that part. Have fun, soenke (1-Jul-2000)