CS 120 / Lab 2 - Feb 4 and 5, 2010 Allison Mankin, amankin1@jhu.edu 1. use 'ps' to observe that your shell is 'tcsh' (Tom's csh) 2. edit ~/.tcshrc to define persistent aliases such as: alias rm 'rm -i' alias gcc120 'gcc -ansi -std=c99 -pedantic -Wall -Wextra -O' start them temporarily by typing 'source ~/.tcshrc' they will be set up every login after this 3. review emacs usage and add some new capabilities ctl-x-ctl-f find or create file ctl-x ctl-s save file ctl-z background emacs, go to command line ctl-z puts any program, not just emacs, in the background type 'fg' (foreground) to return to a ctrl-z'd program if multiple are running, type 'jobs' and then 'fg % to end backgrounded programs new emacs capabilities: ctl-x-2 split screen in 2 ctl-x-1 return to 1 screen (the one cursor is in now) ctl-x-o move cursor to other screen ctl-x-0 close (zero) the screen you're in (but not the file) - your focus moves to the other (or previous) screen ctl-x-ctl-b display buffer list in other window - then use ctl-x-o to enter that screen. Buffers are files you are editing or emacs outputs. When in the buffer list, type an 'f' next to listed file or item and that item will be come to the screen. esc-x-compile in emacs many commands have keystroke bindings but sometimes they have names. A named command like this is entered by typing the ESC key then 'x' then the name, in this case, the word 'compile' 4. simple regular expressions (very basic, useful) * (any number of any character, anywhere), c*, *.c, c*.c [A-Z]*, [a-z]*, [0-9], [Ab3]*.c (everything beginning with A, b or 3), [A-Z][0-9]* (everything beginning with a capital letter followed by a number), etc. 5. exercise: cd to /usr/bin use simple regular expressions, pipes (|) and wc to count the number of programs in /usr/bin that contain the string 'config' and the number that contain the string 'check' e.g. ls *config* | wc -l 6. compilation with emacs and a simple makefile use 'wget' to bring wpa.c to your ugrad home directory emacs wpa.c. ctl-x ctl-f Makefile (create the file named 'Makefile') and edit the following super simple makefile for gpa.c CFLAGS= -ansi -pedantic -Wall -Wextra -std=c99 -O CC=gcc gpa: gpa.c Be sure to save Makefile (ctl-x, ctl-s) Use esc-x-compile and review the compiler output in the emacs window 6. If time permits, use the emacs compiler function by introducing a c error in gpa.c and editing gpa.c, and recompiling. Just save gpa.c each time you edit, before you type esc-x-compile again. 7. Back on the command line, type 'cp wpa.c wpa-copy.c' then back in emacs bring wpa-copy.c into emacs. If time permits, edit a c error into gpa-copy.c and save it Add the following line to Makefile and save it. gpa-copy: gpa-copy.c When you type esc-x-compile, tell emacs to 'make -k gpa-copy' Look with the compile output for the code with an error. Don't correct it. Exit emacs. 8. On the command line, type 'diff wpa.c wpacopy.c > wpadiffs' Type 'cat wpadiffs' and explain what the output means -------------------- Mini-refresher of emacs commands ctrl-p cursor up ctrl-n cursor down ctrl-f cursor forw ctrl-b cursor back ctrl-e cursor to end of line ctrl-a cursor to start of line ctrl-[ cursor to start of flie ctrl-] cursor to end of file ctrl-k cut ctrl-y paste ctrl-o open line above