Speed up loading by merging
This commit is contained in:
		@@ -26,6 +26,8 @@ fi
 | 
			
		||||
 | 
			
		||||
mkdir -p "$RBASH_SOURCES"
 | 
			
		||||
 | 
			
		||||
RBASH_MERGED="$RBASH_SOURCES/merged"
 | 
			
		||||
 | 
			
		||||
# don't put duplicate lines or lines starting with space in the history.
 | 
			
		||||
# See bash(1) for more options
 | 
			
		||||
HISTCONTROL=ignoreboth
 | 
			
		||||
@@ -109,12 +111,32 @@ function rbash_cache {
 | 
			
		||||
    echo -n "$CACHE_FILE"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# User specific aliases and functions
 | 
			
		||||
_RBASH_LOADED=
 | 
			
		||||
function rbash_load {
 | 
			
		||||
    local f path
 | 
			
		||||
 | 
			
		||||
	if [ -z "$_RBASH_UPGRADE" ]; then
 | 
			
		||||
		if [ -n "$_RBASH_LOADED" ]; then
 | 
			
		||||
			return 0
 | 
			
		||||
		fi
 | 
			
		||||
 | 
			
		||||
		if [ -f "$RBASH_MERGED" ]; then
 | 
			
		||||
			source $RBASH_MERGED
 | 
			
		||||
			if [ $? -eq 0 ]; then
 | 
			
		||||
				_RBASH_LOADED=1
 | 
			
		||||
				return 0
 | 
			
		||||
			fi
 | 
			
		||||
			rm "$RBASH_MERGED"
 | 
			
		||||
		fi
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
    echo "Load: $1"
 | 
			
		||||
    f=`rbash_cache "$RBASH_REMOTE/$RBASH_REPO/raw/branch/master/$RBASH_PATH/$1"`
 | 
			
		||||
    source "$f"
 | 
			
		||||
 | 
			
		||||
	echo "echo \"Load: $1\"" >> "$RBASH_MERGED"
 | 
			
		||||
	cat "$f" >> "$RBASH_SOURCES/merged"
 | 
			
		||||
	chmod 700 "$RBASH_MERGED"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function rbash-upgrade {
 | 
			
		||||
@@ -151,7 +173,9 @@ function rbash-upgrade {
 | 
			
		||||
        rm -r "$RBASH_SOURCES"
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
	_RBASH_UPGRADE=1
 | 
			
		||||
    source $__SCRIPT
 | 
			
		||||
	unset _RBASH_UPGRADE
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function rbash-run {
 | 
			
		||||
@@ -219,7 +243,7 @@ function r2ensource {
 | 
			
		||||
		echo "Enabling $_id"
 | 
			
		||||
	done
 | 
			
		||||
	sort $_tmp > "$RBASH_CONFIG"
 | 
			
		||||
	rm $_tmp
 | 
			
		||||
	rm $_tmp "$RBASH_MERGED"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function r2dissource {
 | 
			
		||||
@@ -246,7 +270,7 @@ function r2dissource {
 | 
			
		||||
	_dis=$( mktemp )
 | 
			
		||||
	sh -c "grep -v $_opts \"$RBASH_CONFIG\"" > $_dis
 | 
			
		||||
	sort $_dis > $RBASH_CONFIG
 | 
			
		||||
	rm $_dis
 | 
			
		||||
	rm $_dis "$RBASH_MERGED"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export PS1='This is <MACHINE_NAME>\e[1;3<COLOR_CODE>m<MACHINE_COLORED_NAME>\e[0m: \w\n\$ '
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user