mirror of
https://github.com/opensiriusfox/bashrc.d.git
synced 2025-06-16 20:31:15 -07:00
Added a builder script
The build script reduces the amount of IO on the disk when starting a new bash session. This should speed up the startup time of the shell when under heavy IO load. There is also a short reloader command that calls the builder script when things are modified to avoid hot reloading of the scripts in the directory.
This commit is contained in:
parent
4a75f67b98
commit
148ef9e7ba
6 changed files with 60 additions and 5 deletions
42
0-builder
Normal file
42
0-builder
Normal file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
export IFS=$'\n'
|
||||
|
||||
BASHRC_D="$HOME/.bashrc.d"
|
||||
COMPILED_SRC="$BASHRC_D/1-compiled"
|
||||
echo "Rebuilding $COMPILED_SRC"
|
||||
|
||||
echo """#!/bin/bash
|
||||
# COMPILED AUTOMAGICALLY AT """$(date -I)"""
|
||||
|
||||
""" > $COMPILED_SRC
|
||||
|
||||
SELF_SRC=$(readlink -f $0)
|
||||
for F in $(find $BASHRC_D -maxdepth 1 -iname "*.sh"); do
|
||||
echo " Building in $F"
|
||||
echo "##################" >> $COMPILED_SRC
|
||||
echo "# $(basename $F)" >> $COMPILED_SRC
|
||||
echo "##################" >> $COMPILED_SRC
|
||||
cat $F >> $COMPILED_SRC
|
||||
echo "" >> $COMPILED_SRC
|
||||
done
|
||||
|
||||
HOST_SPECIFIC_SRC="$BASHRC_D/hostname/$(hostname).sh"
|
||||
if [[ -e $HOST_SPECIFIC_SRC ]]; then
|
||||
echo "Adding host specific file $HOST_SPECIFIC_SRC"
|
||||
echo "##################" >> $COMPILED_SRC
|
||||
echo "# $(basename $F)" >> $COMPILED_SRC
|
||||
echo "##################" >> $COMPILED_SRC
|
||||
cat $F >> $COMPILED_SRC
|
||||
echo "" >> $COMPILED_SRC
|
||||
else
|
||||
echo "No host specific file found at $HOST_SPECIFIC_SRC"
|
||||
fi
|
||||
|
||||
echo "##################" >> $COMPILED_SRC
|
||||
echo "# Reloader Script" >> $COMPILED_SRC
|
||||
echo """##################
|
||||
function __rebuild_bashrcd() {
|
||||
bash """$SELF_SRC"""
|
||||
}
|
||||
""" >> $COMPILED_SRC
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue