Operation from document

Documentation is important. Even if you work alone. It saves time  in the future, and the future comes very soon. But writing what you did after the work is hard.

So my way is to write what I will do before the work, and use that note as a script. I usually do not type in the command line directly.

For example, when you want to build GNU tools, you sometimes have to tweak around the options. It would be nice if you can save what you did for the future reference. I usually use meta-level Makefile; for example,

    ~/download/Makefile:
    LIBUSB = libusb-0.1.12
    ROOTFS = $(HOME)/build/rootfs
    libusb-configure:
    cd $(LIBUSB); ./configure \
    --host=mips-ce3m-linux \
    --prefix=$(ROOTFS) \
    2>&1 | tee $(LIBUSB)-configure.log
    libusb-clean:
    $(MAKE) -C $(LIBUSB) clean
    libusb-make:
    $(MAKE) -C $(LIBUSB) 2>&1 | tee $(LIBUSB)-make.log
    libusb-install:
    $(MAKE) -C $(LIBUSB) install 2>&1 | tee $(LIBUSB)-install.log

There is no need of further writing.

For more interactive case, I write the command sequence in my note, which is a big text file: ~/Note. For example,

    make
    objcopy -O binary linux/vmlinux /export/vmlinux.bin
    ssh windows 'lenghthy-ugly-command'

On Emacs, I use F1 key to send those lines to the shell.

    (global-set-key '[f1] (lambda () 
            "Send the current line to the other window."
            (interactive) 
            (let ((a (progn (beginning-of-line) (point)))
                  (b (progn (end-of-line) (point))))
              (kill-ring-save a b))
            (other-window 1) (goto-char (point-max)) 
            (yank) (comint-send-input)
            (other-window 1) (end-of-line 2)))
Advertisements