X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Fcore%2Funter_alia.sh;h=dbf788ff2cd79beb488392b030e781eb3e1e9c21;hb=59c7011aceee4a122495f92de0dc191fbb4f8293;hp=a0c14974201bd36543ce5ce8b24b643f6312dc46;hpb=2952ccf47b80174880141a7ecfa122089f349b8d;p=feisty_meow.git diff --git a/scripts/core/unter_alia.sh b/scripts/core/unter_alia.sh index a0c14974..dbf788ff 100644 --- a/scripts/core/unter_alia.sh +++ b/scripts/core/unter_alia.sh @@ -1,71 +1,58 @@ #!/bin/bash -# generates alias files for different operating systems and shell scripts. +# generates alias files for bash. # -# This script generates command alias definitions for a variety of different -# shells. The "common_aliases.txt" file is used in all of the generated -# files as a base set of generally useful aliases. Then the appropriate -# shell's specific aliases are added in; these are named after the shell that -# they support, e.g. "sh_aliases.txt" is used with the sh and bash shells. -# The third component of the file is a set of aliases generated automatically -# from the names of all the shell scripts in SHELLDIR. -# -# Additionally, if a file named "c_common_aliases.txt" is found in the -# $SHELLDIR/custom directory, then it is added in after the other alias files -# and can override any existing aliases or provide additional local aliases. -# This file is not included with the YETIcode scripts, since it is intended -# to be provided by individual users. -# -# Further, if any other shell-specific alias files are found mirrored under -# the custom folder, they are pulled in as overrides for that kind of shell. -# For example, there is a sh_aliases.txt in the scripts directory for sh, -# but if there's also scripts/custom/c_sh_aliases.txt, then that will be -# plugged in as well. +# The "common.alias" file is used in the generated aliases file as a base +# set of generally useful aliases. We also add aliases for any script files +# (perl, bash, python, etc) that we find in the feisty meow script hierarchy. +# Any *.alias files found in the $FEISTY_MEOW_GENERATED/custom folder are +# loaded also. + +if [ ! -z "$SHELL_DEBUG" ]; then echo rebuiling generated aliases file...; fi # create our generated shells directory if it's not already. -if [ ! -d $GENERADIR ]; then mkdir $GENERADIR; fi +if [ ! -d $FEISTY_MEOW_GENERATED ]; then mkdir $FEISTY_MEOW_GENERATED; fi # test if we can use color in ls... test_color=$(ls --help 2>&1 | grep -i color) -export COMMON_FILES=$SHELLDIR/core/common_aliases.txt -if [ -f "$SHELLDIR/custom/c_common_aliases.txt" ]; then - # if the custom aliases file exists, add it to the list. - export COMMON_FILES="$COMMON_FILES $SHELLDIR/custom/c_common_aliases.txt" -fi -#echo common files is... $COMMON_FILES +# the main one is our common alias set. +ALIAS_DEFINITION_FILES=("$FEISTY_MEOW_SCRIPTS/core/common.alias") + +# if custom aliases files exist, add them to the list. +for i in "$FEISTY_MEOW_GENERATED/custom/*.alias"; do + if [ -f "$i" ]; then + ALIAS_DEFINITION_FILES+=("$i") + fi +done +echo "alias files:" +for i in "${ALIAS_DEFINITION_FILES[@]}"; do + echo " $(basename $(dirname $i))/$(basename $i)" +done # write the aliases for sh and bash scripts. -export ALIASES_FILE="$GENERADIR/aliases.sh" -echo "writing $ALIASES_FILE..." +GENERATED_ALIAS_FILE="$FEISTY_MEOW_GENERATED/fmc_core_and_custom_aliases.sh" +echo "writing generated aliases in $GENERATED_ALIAS_FILE..." #hmmm: perhaps a good place for a function to create the header, # given the appropriate comment code. -echo "##" >$ALIASES_FILE -echo "## generated file: $ALIASES_FILE" >>$ALIASES_FILE -echo "## please do not edit." >>$ALIASES_FILE -echo "##" >>$ALIASES_FILE +echo "##" >$GENERATED_ALIAS_FILE +echo "## generated file: $GENERATED_ALIAS_FILE" >>$GENERATED_ALIAS_FILE +echo "## please do not edit." >>$GENERATED_ALIAS_FILE +echo "##" >>$GENERATED_ALIAS_FILE if [ ! -z "$test_color" ]; then - echo "color_add=--color=auto" >>$ALIASES_FILE + echo "color_add=--color=auto" >>$GENERATED_ALIAS_FILE else - echo "color_add=" >>$ALIASES_FILE + echo "color_add=" >>$GENERATED_ALIAS_FILE fi -# we process the alias file to add the word "alias" to the first of every -# line that's not a comment. -cat $COMMON_FILES | sed -e 's/^\([^#]\)/alias \1/' >>$ALIASES_FILE -echo "##" >>$ALIASES_FILE -echo "## now including shell specific additions..." >>$ALIASES_FILE -echo "##" >>$ALIASES_FILE -# then just dump the sh specific alias stuff into the file. -cat $SHELLDIR/core/sh_aliases.txt >>$ALIASES_FILE -# add in customized sh aliases if they exist. -if [ -f "$SHELLDIR/custom/c_sh_aliases.txt" ]; then - cat $SHELLDIR/custom/c_sh_aliases.txt >>$ALIASES_FILE -fi +# plow in the full set of aliases into the file. +for i in "${ALIAS_DEFINITION_FILES[@]}"; do + cat $i >>$GENERATED_ALIAS_FILE +done -exit 0; +if [ ! -z "$SHELL_DEBUG" ]; then echo done rebuiling generated aliases file.; fi