Appendix A - Surviving Unix
In the Finder, you interact with the operating system graphically, using your mouse. But in the terminal, you interact with the operating system using textual commands. These commands are very powerful, but they can also be very dangerous. You can delete everyfile in your account with a single command! Be careful! Unix is also very smart; it will only let you mess up your own files, not important system files.
Command Result cd directoryname change directory to directoryname cd .. change directory up one level cd change directory to your home directory cd ~ same as cd cd /Users/your-login same as cd cp original duplicate makes a copy of the file original and names it duplicate ls list all the user files and sub-directories in the current directory ls -al give the long listing (size, date, properties, etc) of all (including the non-user) in the current directory mkdir directoryname make a new directory called directoryname mv oldfile newfile renames oldfile with the name newfile. (If there already exists a file newfile, it will be overwritten!) pwd shows the present working directory - i.e. the directory you are in rm filename remove (delete) the file filename rm * remove (delete) all regular files in the current directory - a potentially very dangerous command! rm -r * remove files recursively, i.e. remove all files and directories (and the files they contain!) in the current directory - an even more dangerous command than the one above! Using this call in your root directory will delete all files in your account! And there is no trash bin to retrieve deleted files from! rmdir directoryname remove (delete) an empty directory called directoryname
Appendix B - Navigating Emacs
emacs is a text editor designed primarily for programmers to write source code. It requires textual commands to perform the operations that you might use a mouse for in a word-processor. But keyboard commands, once you get to know them, are faster than using a mouse and drop-down menus. (There are versions of emacs, or xemacs, that provide this functionality but I don't think that they are installed on the Mac's in the lab.) Other common versions of emacs allow the use of a mouse to select and paste text easily, but they need a three-button mouse (which is the standard mouse on Unix).This is not a comprehensive manual - there are whole books on emacs - but it should provide enough information for your current needs. (If you need more detailed information, Google returns over 90,000 links to emacs tutorials on the 'net!)
Note: I only spent a few minutes using emacs on the Mac's in the lab, so I don't know how much functionality we have access to. I'll look into it when I'm back at the school in January.
If a command is written here as C-x C-s, you press the Control key and the letter x simultaneously, followed by the Control key and the letter s simultaneously. (This command saves the current file you're working on.)
M-d means press the Meta key and d at simultaneously. I'm not sure what the Meta key is on the Mac; try ESC or ALT.
There is a line at the bottom of the screen called the minibuffer. You will have to enter information into the minibuffer when using certain commands, such as when opening a file: you will have to enter the name of the file to be opened.
To open emacs (from the prompt in the terminal) emacs Opens the text editor emacs filename.cpp Opens the text editor and the file filename.cpp
If the file does not exist, a new file called filename.cpp will be created
Commands issued within the text editor C-x C-f Find (open) file - after the command, you'll have to specify which file in the minibuffer. If the required file is already open in emacs, it will be brought to the front. If there is no such file in the current directory, an empty file will be created with the name you just specified. C-x C-s Save current file C-x C-w Write the current file - same as the 'File -> Save As' command in a word processor. Enter the new file name in the minibuffer. C-x C-c Close emacs C-e Move cursor to the end of the line C-a Move cursor to the beginning of the line (emacs has commands to move the cursor forward one character, back one character, up one line and down one line, but I find it as easy to use the arrow keys) C-d Kill character to right of cursor (or above cursor if you have a block cursor) DEL Kill character to the left of the cursor M-d Kill word to right of cursor M-DEL Kill word to the left of cursor C-k Kill from the cursor to the end of the line (but not the newline, or carriage return, character so to kill a whole line you have to do the command twice, C-k C-k) C-y Yank (paste) killed text All the above kill commands save the killed text; it can be pasted back in a new location to get a 'cut and paste'.
There is no 'copy and paste' so you need to delete, paste back immediately, and then go to where you want to paste to simulate a 'cut and paste'
C-g Abandon the current command - you may occasionally need to perform this command more than once. C-_ Undo last - can be repeated to undo more than one action (some keyboards require C-x u). There is 'infinite' undo, even through saves, back to when file was last opened.
There is no specific redo. To redo, stop the undo (enter any character) and then call undo again - this undoes the previous 'undo last' commands, creating a redo!
C-s Search for text: enter the text string into the minibuffer.
Repeat the command for the next occurrence (you shouldn't need to re-enter the text string.
Press return to leave the search.
C-r Reverse search M-% Query search and replace. You will be prompted for the text string that you are searching for, and then prompted for what to replace with. When the search string is found, you have a number of options:
spacebar - replace this string occurrence
delete - ignore this replacement
return or escape - quit query search
Also, y(es) for replace, n(o) for don't replace might work.
This is a particularly useful function when programming, especially if you want to change variable names consistently throughout your program.
Appendix C - Glossary
Appendix D - Reserved Keywords
The following are words that are reserved for special use by C++ and may not be declared as user-defined identifiers within a program.
asm auto bool break case catch char class const const_cast continue default delete do double dynamic_cast else enum explicit export extern false float for friend goto if inline int long mutable namespace new operator private protected public register reinterpret_cast return short signed sizeof static static_cast struct switch template this throw true try typedef typeid typename union unsigned using virtual void volatile wchar_t while