Created
March 8, 2012 02:58
-
-
Save itsthatguy/1998267 to your computer and use it in GitHub Desktop.
Bootslap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BSTITLE="\033[0;33m" | |
BSCODE="\033[1;33m" | |
BSCLEAN="\033[0m" | |
BOOTSLAP='' | |
function decorate { | |
local base=$1 | |
local feature=$2 | |
local undecorated="${base}_without_${feature}" | |
local decorated="${base}_with_${feature}" | |
# Define $undecorated with $base's body | |
eval "$(echo 'function' $undecorated; declare -f $base | tail -n +2)" | |
# Define $base with $decorated's body | |
eval "$(echo 'function' $base; declare -f $decorated | tail -n +2)" | |
} | |
function cd_with_bootslap () { | |
cd_without_bootslap "$@" && bootslap | |
} | |
decorate cd bootslap | |
function bs () { | |
if [ -f "$BOOTSLAP/.bootslap" ]; then | |
echo -en "\n${BSTITLE}Bootslap: ${BOOTSLAP}\n----------" | |
perl -e "print '-' x ${#BOOTSLAP}" | |
echo -e ${BSCODE} | |
cat "$BOOTSLAP/.bootslap"; | |
echo -e "${BSCLEAN}"; | |
else | |
echo -e "${BSTITLE}Bootslap: ${BSCODE}Nothing to Bootslap!${BSCLEAN}"; | |
fi | |
} | |
function bootslap () { | |
PD="$(pwd -L)/" | |
if [[ "${PD}" != "${BOOTSLAP}" ]] && [ -f ".bootslap" ]; then | |
BOOTSLAP="${PD}" | |
bs | |
elif [[ "${PD:0:${#BOOTSLAP}}" != "${BOOTSLAP}" ]]; then | |
BOOTSLAP='' | |
fi | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I should live in your project directory just like this, enter anything here. | |
Commands: | |
bs # This will echo the bootslap file for your project, from any directory within the project. | |
Running the server: | |
Lein repl | |
(dev-server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment