#!/bin/bash # Copyright by # Scott D. Anderson # scott.anderson@acm.org # Released under the GNU General Public License # The TW software is fully contained in its directory tree: it doesn't # insinuate itself into other parts of your computer. However, compiling # using the TW Makefile is annoying without an alias, so this script adds # an alias to your login script # This script assumes that it is called with the TWHOME directory as its first arg # Note that aliases are shell-specific, so you have to *source* this # script in the shell that you want to have the alias, not execute it. # Can't exit in this script, because we are sourcing it! if [ "x${1}x" = "xx" ]; then echo "Usage: source install-tw TWHOME" else export TWHOME=$1 echo "TWHOME is ${TWHOME}" alias make-tw="make -f ${TWHOME}/Makefile" # Add the environment variable and alias to the ~/.bashrc, so that # every new shell gets it. Technically, the environment variable # should go in ~/.bash_profile, but this is fine and reduces the # number of files we are messing with. if [ ! -e ~/.bashrc ]; then touch ~/.bashrc fi # checking with grep makes this idempotent, but it means that # erroneous aliases don't get over-written. This grep is unnecessary # if the file is empty, but the following style of coding avoids # repeating the echo commands. if ! grep 'make-tw' ~/.bashrc > /dev/null ; then echo "adding stuff to ~/.bashrc" echo "export TWHOME=${TWHOME}" >> ~/.bashrc echo "alias make-tw=\"make -f ${TWHOME}/Makefile\"" >> ~/.bashrc else echo "stuff is already in ~/.bashrc." fi # end the main enclosing if fi