#!/bin/sh
# Install nano — create command trampolines in ../bin/
dir=`dirname "$0"`
case "$dir" in
    /*) ;;
    *)  dir="`pwd`/$dir" ;;
esac
dir=`cd "$dir" && pwd`
bundle=`basename "$dir"`
bindir=`dirname "$dir"`/bin
mkdir -p "$bindir"
echo "Installing nano commands into $bindir"
echo '#!/bin/sh' > "$bindir/captoinfo"
echo 'dir=`dirname "$0"`' >> "$bindir/captoinfo"
echo 'case "$dir" in /*) ;; *) dir="`pwd`/$dir" ;; esac' >> "$bindir/captoinfo"
echo "exec \"\$dir/../$bundle/captoinfo\" \"\$@\"" >> "$bindir/captoinfo"
chmod 755 "$bindir/captoinfo" && echo "  captoinfo"
echo '#!/bin/sh' > "$bindir/clear"
echo 'dir=`dirname "$0"`' >> "$bindir/clear"
echo 'case "$dir" in /*) ;; *) dir="`pwd`/$dir" ;; esac' >> "$bindir/clear"
echo "exec \"\$dir/../$bundle/clear\" \"\$@\"" >> "$bindir/clear"
chmod 755 "$bindir/clear" && echo "  clear"
echo '#!/bin/sh' > "$bindir/infocmp"
echo 'dir=`dirname "$0"`' >> "$bindir/infocmp"
echo 'case "$dir" in /*) ;; *) dir="`pwd`/$dir" ;; esac' >> "$bindir/infocmp"
echo "exec \"\$dir/../$bundle/infocmp\" \"\$@\"" >> "$bindir/infocmp"
chmod 755 "$bindir/infocmp" && echo "  infocmp"
echo '#!/bin/sh' > "$bindir/infotocap"
echo 'dir=`dirname "$0"`' >> "$bindir/infotocap"
echo 'case "$dir" in /*) ;; *) dir="`pwd`/$dir" ;; esac' >> "$bindir/infotocap"
echo "exec \"\$dir/../$bundle/infotocap\" \"\$@\"" >> "$bindir/infotocap"
chmod 755 "$bindir/infotocap" && echo "  infotocap"
echo '#!/bin/sh' > "$bindir/nano"
echo 'dir=`dirname "$0"`' >> "$bindir/nano"
echo 'case "$dir" in /*) ;; *) dir="`pwd`/$dir" ;; esac' >> "$bindir/nano"
echo "exec \"\$dir/../$bundle/nano\" \"\$@\"" >> "$bindir/nano"
chmod 755 "$bindir/nano" && echo "  nano"
echo '#!/bin/sh' > "$bindir/reset"
echo 'dir=`dirname "$0"`' >> "$bindir/reset"
echo 'case "$dir" in /*) ;; *) dir="`pwd`/$dir" ;; esac' >> "$bindir/reset"
echo "exec \"\$dir/../$bundle/reset\" \"\$@\"" >> "$bindir/reset"
chmod 755 "$bindir/reset" && echo "  reset"
echo '#!/bin/sh' > "$bindir/rnano"
echo 'dir=`dirname "$0"`' >> "$bindir/rnano"
echo 'case "$dir" in /*) ;; *) dir="`pwd`/$dir" ;; esac' >> "$bindir/rnano"
echo "exec \"\$dir/../$bundle/rnano\" \"\$@\"" >> "$bindir/rnano"
chmod 755 "$bindir/rnano" && echo "  rnano"
echo '#!/bin/sh' > "$bindir/tabs"
echo 'dir=`dirname "$0"`' >> "$bindir/tabs"
echo 'case "$dir" in /*) ;; *) dir="`pwd`/$dir" ;; esac' >> "$bindir/tabs"
echo "exec \"\$dir/../$bundle/tabs\" \"\$@\"" >> "$bindir/tabs"
chmod 755 "$bindir/tabs" && echo "  tabs"
echo '#!/bin/sh' > "$bindir/tic"
echo 'dir=`dirname "$0"`' >> "$bindir/tic"
echo 'case "$dir" in /*) ;; *) dir="`pwd`/$dir" ;; esac' >> "$bindir/tic"
echo "exec \"\$dir/../$bundle/tic\" \"\$@\"" >> "$bindir/tic"
chmod 755 "$bindir/tic" && echo "  tic"
echo '#!/bin/sh' > "$bindir/toe"
echo 'dir=`dirname "$0"`' >> "$bindir/toe"
echo 'case "$dir" in /*) ;; *) dir="`pwd`/$dir" ;; esac' >> "$bindir/toe"
echo "exec \"\$dir/../$bundle/toe\" \"\$@\"" >> "$bindir/toe"
chmod 755 "$bindir/toe" && echo "  toe"
echo '#!/bin/sh' > "$bindir/tput"
echo 'dir=`dirname "$0"`' >> "$bindir/tput"
echo 'case "$dir" in /*) ;; *) dir="`pwd`/$dir" ;; esac' >> "$bindir/tput"
echo "exec \"\$dir/../$bundle/tput\" \"\$@\"" >> "$bindir/tput"
chmod 755 "$bindir/tput" && echo "  tput"
echo '#!/bin/sh' > "$bindir/tset"
echo 'dir=`dirname "$0"`' >> "$bindir/tset"
echo 'case "$dir" in /*) ;; *) dir="`pwd`/$dir" ;; esac' >> "$bindir/tset"
echo "exec \"\$dir/../$bundle/tset\" \"\$@\"" >> "$bindir/tset"
chmod 755 "$bindir/tset" && echo "  tset"
echo ""
echo "Done. Make sure $bindir is in your PATH:"
echo "  PATH=$bindir:\$PATH; export PATH"
echo ""
echo "Add that line to ~/.profile to make it permanent."
