aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfig.bsh44
1 files changed, 28 insertions, 16 deletions
diff --git a/config.bsh b/config.bsh
index 2b32fff..b1123b4 100755
--- a/config.bsh
+++ b/config.bsh
@@ -21,7 +21,9 @@
# HISTORY
# 2015.12.25 V 2.1 Initial Version.
# +A.M.Danischewski <adam_ lastname@not gamil.com>
-#
+# 2015.12.25 V 2.1 Moved alias file to a variable, cleaned up some
+# alias logic. Now, $> i2h nasm == $> i2h nasm TOP
+# +A.M.Danischewski <adam_ lastname@not gamil.com>
# Caveat: If you are using not Linux (e.g. Unix), change the DISCARD_DEV
# below from /dev/random to /dev/null.
#
@@ -29,22 +31,32 @@
declare -r TESTURL="http://localhost:8000/info2html?%28coreutils.info.gz%29Common%2520options"
declare -ir PHP_PORT=8000
-declare -r FAV_WEBBROWSER=firefox ### CHANGE THIS IF NECESSARY
-declare -r DISCARD_DEV="/dev/random" ### CHANGE IF NECESSARY,/dev/null
+declare -r FAV_WEBBROWSER=firefox ### CHANGE THIS IF NECESSARY
+declare -r DISCARD_DEV="/dev/random" ### CHANGE IF NECESSARY,/dev/null
+declare -r I2H_ALIASFILE="i2h.alias"
-echo "Starting php built-in web server ... "
+echo "Starting php built-in web server ... "
php -S localhost:${PHP_PORT} -t / $(pwd)/routing.php &>"${DISCARD_DEV}" &
-echo "Checking for ${FAV_WEBBROWSER} and loading a test url: "
-echo " ${TESTURL} ..."
+echo "Checking for ${FAV_WEBBROWSER} and loading a test url: "
+echo " ${TESTURL} ..."
which "${FAV_WEBBROWSER}" &>"${DISCARD_DEV}" && "${FAV_WEBBROWSER}" "${TESTURL}" || echo "Point your favorite web browser at: ${TESTURL}"
-echo "The following alias will run the html version of info, if you don't have firefox edit this script to your favorite browser. It will check if the php server is running and launch info2html."
-echo "Creating i2h.alias file.. "
-echo "alias i2h='_(){ main=\${1}; shift; ((\$#==0)) && starturl=\"infocat\" || starturl=\"info2html?(\${main})\$(sed \"s/ /%2520/g\" <<< \"\${@:-TOP}\")\"; port=${PHP_PORT}; netstat -an | { ! grep -q \":\${port}.*LISTEN\"; } && (php -S localhost:\${port} -t / $(pwd)/routing.php &>\"${DISCARD_DEV}\" & ); firefox \"http://localhost:\${port}/\${starturl}\"; }; _'" > i2h.alias
-echo -e "\nAdd the alias entry in the i2h.alias file to your .bashrc file. "
-echo -e "\nalias i2h='_(){ main=\${1}; shift; ((\$#==0)) && starturl=\"infocat\" || starturl=\"info2html?(\${main})\$(sed \"s/ /%2520/g\" <<< \"\${@:-TOP}\")\"; port=${PHP_PORT}; netstat -an | { ! grep -q \":\${port}.*LISTEN\"; } && (php -S localhost:\${port} -t / $(pwd)/routing.php &>\"${DISCARD_DEV}\" & ); firefox \"http://localhost:\${port}/\${starturl}\"; }; _'\n"
-echo "You should now be able to run info whenever you want as follows:"
-echo "\$> i2h coreutils wc invocation"
-echo " ## Or, to bring up the info catalog. Simply i2h by itself:"
-echo "\$> i2h "
-echo "Done!! ..."
+echo "The following alias will run the html version of info, if you don't have firefox edit this script to your favorite browser. It will check if the php server is running and launch info2html."
+echo "Creating ${I2H_ALIASFILE} file.. "
+echo "alias i2h='_(){ main=\${1}; ((\$#==0)) && starturl=\"infocat\" || { shift; starturl=\"info2html?(\${main})\$(sed \"s/ /%2520/g\" <<< \"\${@:-TOP}\")\";}; port=${PHP_PORT}; netstat -an | { ! grep -q \":\${port}.*LISTEN\"; } && (php -S localhost:\${port} -t / $(pwd)/routing.php &>\"${DISCARD_DEV}\" & ); firefox \"http://localhost:\${port}/\${starturl}\"; }; _'" > ./"${I2H_ALIASFILE}"
+echo -e "\n *** MANUAL STEP *** "
+echo " * Source the alias file, as follows: "
+echo " $> . ${I2H_ALIASFILE}"
+echo " * Test it as follows: "
+echo " $> i2h "
+echo " * Edit the alias (if necessary) until it works."
+echo " * Add the alias entry in the i2h.alias file to your .bashrc file. "
+echo -e "\nalias i2h='_(){ main=\${1}; ((\$#==0)) && starturl=\"infocat\" || { shift; starturl=\"info2html?(\${main})\$(sed \"s/ /%2520/g\" <<< \"\${@:-TOP}\")\";}; port=${PHP_PORT}; netstat -an | { ! grep -q \":\${port}.*LISTEN\"; } && (php -S localhost:\${port} -t / $(pwd)/routing.php &>\"${DISCARD_DEV}\" & ); firefox \"http://localhost:\${port}/\${starturl}\"; }; _'\n"
+echo "After sourcing/adding the alias in .bashrc; you can run info2html, via i2h alias, as follows:"
+echo " \$> i2h coreutils wc invocation"
+echo " ## Or, to bring up the info catalog, with simply i2h by itself:"
+echo " \$> i2h "
+echo -e "\n Done!!\n"
+echo " Notes: "
+echo " If you move this software to a new home, just re-run ${0##/} to a generate a new alias."
+echo " The PHP webserver stays in bg, you may also want a new alias w/\"kill \$(pidof php)\"."
exit 0