X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Fcore%2Funter_alia.sh;fp=scripts%2Fcore%2Funter_alia.sh;h=43c414cb5a26d1dc412db640f2cd218cf368ceb1;hb=dbe3a7d9104352d69efdaa5eca600908ecc9bba8;hp=644ca2989e8fa8271f93f53f1f3cf7eaac149065;hpb=59b77297ccc18200384ec402bb8d4383386b8141;p=feisty_meow.git diff --git a/scripts/core/unter_alia.sh b/scripts/core/unter_alia.sh index 644ca298..43c414cb 100644 --- a/scripts/core/unter_alia.sh +++ b/scripts/core/unter_alia.sh @@ -1,74 +1,59 @@ #!/bin/bash # generates alias files for different operating systems and shell scripts. +# or really, mainly for bash these days, on linux. but we also run under +# msys and cygwin to some degree. # -# This script generates command alias definitions for a variety of different -# shells. The "common.alias" 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. +# The "common.alias" file is used in the generated aliases file as a base +# set of generally useful aliases. Shorter aliases based on any scripts +# we can find in the feisty meow script hierarchy are added in as well. # -# 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. +# If any other alias files are found in the scripts/custom folder, they +# are pulled in as additions and overrides for the basic feisty meow command +# set. + +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 +ALIAS_DEFINITION_FILES=("$FEISTY_MEOW_SCRIPTS/core/common.alias") # if custom aliases files exist, add them to the list. -for i in "$SHELLDIR/custom/*.txt"; do - COMMON_FILES+=" $i" +for i in "$FEISTY_MEOW_SCRIPTS/custom/*.alias"; do +echo adding $i + ALIAS_DEFINITION_FILES+=("$i") +done +echo "alias files:" +for i in "${ALIAS_DEFINITION_FILES[@]}"; do + echo " $(basename $(dirname $i))/$(basename $i)" done -echo -e "Found alias files:\n$COMMON_FILES" # write the aliases for sh and bash scripts. -export ALIASES_FILE="$GENERADIR/aliases.sh" -echo "writing $ALIASES_FILE..." +GENERATED_ALIAS_FILE="$FEISTY_MEOW_GENERATED/aliases.sh" +echo "writing $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 -#nope: we no longer do that. - -cat $COMMON_FILES >>$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 +if [ ! -z "$SHELL_DEBUG" ]; then echo done rebuiling generated aliases file.; fi