2012-06-21 02:08:01 +03:00
|
|
|
install_prelude () {
|
2012-12-09 18:42:13 +02:00
|
|
|
printf " Cloning the Prelude's GitHub repository...\n$RESET"
|
2012-06-21 02:08:01 +03:00
|
|
|
if [ x$PRELUDE_VERBOSE != x ]
|
|
|
|
then
|
2012-12-09 18:18:40 +02:00
|
|
|
/usr/bin/env git clone $PRELUDE_URL $PRELUDE_INSTALL_DIR
|
2012-06-21 02:08:01 +03:00
|
|
|
else
|
2012-12-09 18:42:13 +02:00
|
|
|
/usr/bin/env git clone $PRELUDE_URL $PRELUDE_INSTALL_DIR > /dev/null
|
2012-06-21 02:08:01 +03:00
|
|
|
fi
|
|
|
|
if ! [ $? -eq 0 ]
|
|
|
|
then
|
2012-12-09 18:42:13 +02:00
|
|
|
printf "$RED A fatal error occurred during Prelude's installation. Aborting..."
|
2012-12-09 18:18:40 +02:00
|
|
|
exit 1
|
2012-06-21 02:08:01 +03:00
|
|
|
fi
|
|
|
|
}
|
2012-02-16 16:25:18 +02:00
|
|
|
|
2012-06-21 02:08:01 +03:00
|
|
|
make_prelude_dirs () {
|
|
|
|
printf " Making the required directories.\n$RESET"
|
2012-06-23 12:42:02 +03:00
|
|
|
mkdir $PRELUDE_INSTALL_DIR/vendor $PRELUDE_INSTALL_DIR/personal
|
|
|
|
mkdir $PRELUDE_INSTALL_DIR/themes $PRELUDE_INSTALL_DIR/snippets
|
|
|
|
mkdir $PRELUDE_INSTALL_DIR/savefile
|
2012-06-21 02:08:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
colors () {
|
2012-12-09 18:18:40 +02:00
|
|
|
# Reset
|
2012-06-21 02:08:01 +03:00
|
|
|
RESET='\e[0m'
|
|
|
|
RED='\e[0;31m' # Red
|
|
|
|
GREEN='\e[0;32m' # Green
|
|
|
|
YELLOW='\e[0;33m' # Yellow
|
|
|
|
BLUE='\e[0;34m' # Blue
|
|
|
|
PURPLE='\e[0;35m' # Purple
|
|
|
|
CYAN='\e[0;36m' # Cyan
|
|
|
|
WHITE='\e[0;37m' # White
|
|
|
|
|
2012-12-09 18:18:40 +02:00
|
|
|
# Bold
|
2012-06-21 02:08:01 +03:00
|
|
|
BRED='\e[1;31m' # Red
|
|
|
|
BGREEN='\e[1;32m' # Green
|
|
|
|
BYELLOW='\e[1;33m' # Yellow
|
|
|
|
BBLUE='\e[1;34m' # Blue
|
|
|
|
BPURPLE='\e[1;35m' # Purple
|
|
|
|
BCYAN='\e[1;36m' # Cyan
|
|
|
|
BWHITE='\e[1;37m' # White
|
|
|
|
}
|
|
|
|
|
|
|
|
# Commandline args:
|
|
|
|
# -d/--directory [dir]
|
|
|
|
# Install prelude into the specified directory. If 'dir' is a relative path prefix it with $HOME.
|
|
|
|
# Defaults to '$HOME/.emacs.d'
|
|
|
|
# -c/--colors
|
|
|
|
# Enable colors
|
|
|
|
# -s/--source [url]
|
|
|
|
# Clone prelude from 'url'.
|
|
|
|
# Defaults to 'https://github.com/bbatsov/prelude.git'
|
|
|
|
# -i/--into
|
|
|
|
# If one exists, install into the existing config
|
|
|
|
# -n/--no-bytecompile
|
|
|
|
# Skip the compilation of the prelude files.
|
|
|
|
# -h/--help
|
|
|
|
# Print help
|
|
|
|
# -v/--verbose
|
|
|
|
# Verbose output, for debugging
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
printf "Usage: $0 [OPTION]\n"
|
2012-10-03 00:52:10 +03:00
|
|
|
printf " -c, --colors \t \t \t Enable colors.\n"
|
2012-06-21 02:08:01 +03:00
|
|
|
printf " -d, --directory [dir] \t Install prelude into the specified directory.\n"
|
|
|
|
printf " \t \t \t \t If 'dir' is a relative path prefix with $HOME.\n"
|
|
|
|
printf " \t \t \t \t Defaults to $HOME/.emacs.d\n"
|
|
|
|
printf " -s, --source [url] \t \t Clone prelude from 'url'.\n"
|
|
|
|
printf " \t \t \t \t Defaults to 'https://github.com/bbatsov/prelude.git'.\n"
|
|
|
|
printf " -n, --no-bytecompile \t \t Skip the bytecompilation step of prelude.\n"
|
|
|
|
printf " -i, --into \t \t \t Install Prelude into the existing configuration\n"
|
|
|
|
printf " \t \t \t \t The default behavious is to install prelude into the existing\n"
|
|
|
|
printf " \t \t \t \t emacs configuration.\n"
|
|
|
|
printf " -h, --help \t \t \t Display this help and exit\n"
|
|
|
|
printf " -v, --verbose \t \t Display verbose information\n"
|
|
|
|
printf "\n"
|
|
|
|
}
|
2012-05-11 13:36:57 +03:00
|
|
|
|
2012-06-21 02:08:01 +03:00
|
|
|
### Parse cli
|
|
|
|
while [ $# -gt 0 ]
|
|
|
|
do
|
|
|
|
case $1 in
|
2012-12-09 18:18:40 +02:00
|
|
|
-d | --directory)
|
|
|
|
PRELUDE_INSTALL_DIR=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
-c | --colors)
|
|
|
|
colors
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
-s | --source)
|
|
|
|
PRELUDE_URL=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
-i | --into)
|
|
|
|
PRELUDE_INTO='true'
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
-n | --no-bytecompile)
|
|
|
|
PRELUDE_SKIP_BC='true'
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
-h | --help)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
-v | --verbose)
|
|
|
|
echo "prelude verbose $PRELUDE_VERBOSE"
|
|
|
|
PRELUDE_VERBOSE='true';
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
printf "Unkown option: $1\n"
|
|
|
|
shift 1
|
|
|
|
;;
|
2012-06-21 02:08:01 +03:00
|
|
|
esac
|
|
|
|
done
|
2012-05-07 17:38:16 +03:00
|
|
|
|
2012-06-21 02:08:01 +03:00
|
|
|
VERBOSE_COLOR=$BBLUE
|
2012-05-07 17:38:16 +03:00
|
|
|
|
2012-06-23 12:24:41 +03:00
|
|
|
[ -z $PRELUDE_URL ] && PRELUDE_URL="https://github.com/bbatsov/prelude.git"
|
|
|
|
[ -z $PRELUDE_INSTALL_DIR ] && PRELUDE_INSTALL_DIR="$HOME/.emacs.d"
|
2012-02-17 12:34:08 +02:00
|
|
|
|
2012-06-21 02:08:01 +03:00
|
|
|
if [ x$PRELUDE_VERBOSE != x ]
|
2012-02-16 16:25:18 +02:00
|
|
|
then
|
2012-06-21 02:08:01 +03:00
|
|
|
printf "$PRELUDE_VERBOSE\n"
|
|
|
|
printf "$VERBOSE_COLOR"
|
|
|
|
printf "INSTALL_DIR = $PRELUDE_INSTALL_DIR\n"
|
|
|
|
printf "SOURCE_URL = $PRELUDE_URL\n"
|
|
|
|
if [ -n $PRELUDE_SKIP_BC ]
|
|
|
|
then
|
2012-12-09 18:18:40 +02:00
|
|
|
printf "Skipping bytecompilation.\n"
|
2012-06-21 02:08:01 +03:00
|
|
|
fi
|
|
|
|
if [ -n $PRELUDE_INTO ]
|
|
|
|
then
|
2012-12-09 18:18:40 +02:00
|
|
|
printf "Replacing existing config (if one exists).\n"
|
2012-06-21 02:08:01 +03:00
|
|
|
fi
|
|
|
|
printf "$RESET"
|
|
|
|
fi
|
|
|
|
|
2012-06-23 12:44:29 +03:00
|
|
|
# If prelude is already installed
|
2012-12-15 22:07:25 +02:00
|
|
|
if [ -d $PRELUDE_INSTALL_DIR/core/prelude-core.el ]
|
2012-06-23 12:44:29 +03:00
|
|
|
then
|
|
|
|
printf "\n\n$BRED"
|
|
|
|
printf "You already have Prelude installed.$RESET\nYou'll need to remove $PRELUDE_INSTALL_DIR/prelude if you want to install Prelude again.\n"
|
|
|
|
printf "If you want to update your copy of prelude, run 'git pull origin master' from your prelude directory\n\n"
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
2012-06-21 02:08:01 +03:00
|
|
|
### Check dependencies
|
|
|
|
printf "$CYAN Checking to see if git is installed... $RESET"
|
|
|
|
if hash git 2>&-
|
2012-02-16 16:25:18 +02:00
|
|
|
then
|
2012-06-21 02:08:01 +03:00
|
|
|
printf "$GREEN found.$RESET\n"
|
2012-05-11 13:36:57 +03:00
|
|
|
else
|
2012-06-21 02:08:01 +03:00
|
|
|
printf "$RED not found. Aborting installation!$RESET\n"
|
|
|
|
exit 1
|
|
|
|
fi;
|
|
|
|
|
|
|
|
printf "$CYAN Checking to see if aspell is installed... "
|
|
|
|
if hash aspell 2>&-
|
|
|
|
then
|
|
|
|
printf "$GREEN found.$RESET\n"
|
|
|
|
else
|
|
|
|
print "$RED not found. Install aspell to benefit from flyspell-mode!$RESET\n"
|
2012-02-16 16:25:18 +02:00
|
|
|
fi
|
|
|
|
|
2012-06-21 02:08:01 +03:00
|
|
|
printf "$CYAN Checking to see if ack is installed... "
|
|
|
|
if hash ack 2>&-
|
|
|
|
then
|
|
|
|
printf "$GREEN found.$RESET\n"
|
|
|
|
else
|
|
|
|
printf "$RED not found. You'll need it to use ack-and-a-half!$RESET\n"
|
|
|
|
fi
|
|
|
|
|
|
|
|
### Check emacs version
|
2012-06-16 16:24:36 +03:00
|
|
|
if [ $(emacs --version 2>/dev/null | sed -n 's/.*[^0-9.]\([0-9]*\.[0-9.]*\).*/\1/p;q' | sed 's/\..*//g') -lt 24 ]
|
|
|
|
then
|
2012-06-21 02:08:01 +03:00
|
|
|
printf "$YELLOW WARNING:$RESET Prelude depends on emacs $RED 24$RESET !\n"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d $PRELUDE_INSTALL_DIR ] || [ -f $PRELUDE_INSTALL_DIR ]
|
|
|
|
then
|
|
|
|
# Existing file/directory found -> backup
|
|
|
|
printf " Backing up the existing config to $PRELUDE_INSTALL_DIR.pre-prelude.tar.\n"
|
|
|
|
tar -cf $PRELUDE_INSTALL_DIR.pre-prelude.tar $PRELUDE_INSTALL_DIR > /dev/null 2>&1
|
|
|
|
# Overwrite existing?
|
|
|
|
if [ -n $PRELUDE_INTO ]
|
|
|
|
then
|
2012-12-09 18:18:40 +02:00
|
|
|
# Replace existing config
|
|
|
|
install_prelude
|
|
|
|
make_prelude_dirs
|
2012-11-02 12:25:23 +02:00
|
|
|
else
|
2012-12-09 18:18:40 +02:00
|
|
|
# Install into existing config
|
|
|
|
PRELUDE_INSTALL_DIR=$PRELUDE_INSTALL_DIR"/prelude"
|
|
|
|
install_prelude
|
2012-06-21 02:08:01 +03:00
|
|
|
fi
|
|
|
|
elif [ -e $PRELUDE_INSTALL_DIR ]
|
|
|
|
then
|
|
|
|
# File exist but not a regular file or directory
|
|
|
|
# WTF NOW?
|
|
|
|
printf "$BRED $PRELUDE_INSTALL_DIR exist but isn't a file or directory.\n"
|
|
|
|
printf "$BRED please remove this file or install prelude in a different directory"
|
|
|
|
printf "$BRED (-d flag)\n$RESET"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
# Nothing yet so just install prelude
|
|
|
|
install_prelude
|
|
|
|
make_prelude_dirs
|
2013-01-13 20:42:17 +02:00
|
|
|
cp $PRELUDE_INSTALL_DIR/sample/prelude-modules.el $PRELUDE_INSTALL_DIR
|
2012-06-21 02:08:01 +03:00
|
|
|
fi
|
2012-05-11 16:06:40 +03:00
|
|
|
|
2012-06-21 02:08:01 +03:00
|
|
|
if [ -z $PRELUDE_SKIP_BC ];
|
2012-05-11 16:06:40 +03:00
|
|
|
then
|
2012-06-21 02:08:01 +03:00
|
|
|
if which emacs 2>&1 > /dev/null
|
|
|
|
then
|
2012-12-09 18:18:40 +02:00
|
|
|
printf " Bytecompiling Prelude.\n"
|
|
|
|
if [ x$PRELUDE_VERBOSE != x ]
|
|
|
|
then
|
2013-01-13 20:42:17 +02:00
|
|
|
emacs -batch -f batch-byte-compile $PRELUDE_INSTALL_DIR/core/*.el
|
2012-12-09 18:18:40 +02:00
|
|
|
else
|
2013-01-13 20:42:17 +02:00
|
|
|
emacs -batch -f batch-byte-compile $PRELUDE_INSTALL_DIR/core/*.el > /dev/null 2>&1
|
2012-12-09 18:18:40 +02:00
|
|
|
fi
|
2012-06-21 02:08:01 +03:00
|
|
|
else
|
2012-12-09 18:18:40 +02:00
|
|
|
printf "$YELLOW Emacs not found.$RESET Skipping bytecompilation.\n"
|
2012-06-21 02:08:01 +03:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
printf "Skipping bytecompilation.\n"
|
2012-05-11 16:06:40 +03:00
|
|
|
fi
|
2012-02-16 16:25:18 +02:00
|
|
|
|
2012-06-21 02:08:01 +03:00
|
|
|
# Print usage message if prelude didn't replace .emacs.d
|
2012-06-23 12:47:06 +03:00
|
|
|
# if [ $PRELUDE_INSTALL_DIR != "$HOME/.emacs.d" ]
|
|
|
|
# then
|
|
|
|
# printf "\n To use prelude, add: $CYAN\n (defvar prelude-dir \"$PRELUDE_INSTALL_DIR/\")\n"
|
|
|
|
# printf " (load-file (concat prelude-dir \"init.el\"))\n$RESET"
|
|
|
|
# printf " To your emacs init file.\n\n"
|
|
|
|
# fi
|
2012-02-16 16:25:18 +02:00
|
|
|
|
2012-06-21 02:08:01 +03:00
|
|
|
printf "\n"
|
|
|
|
printf "$BBLUE ____ _ _ \n"
|
|
|
|
printf "$BBLUE | _ \ _ __ ___| |_ _ __| | ___ \n"
|
|
|
|
printf "$BBLUE | |_) | __/ _ \ | | | |/ _ |/ _ \ \n"
|
|
|
|
printf "$BBLUE | __/| | | __/ | |_| | (_| | __/ \n"
|
|
|
|
printf "$BBLUE |_| |_| \___|_|\__,_|\__,_|\___| \n\n"
|
|
|
|
printf "$GREEN ... is now installed and ready to do thy bidding, Master $USER!$RESET\n"
|
2013-01-13 20:42:17 +02:00
|
|
|
printf "$GREEN Don't forget to adjust the modules you want to use in $PRELUDE_INSTALL_DIR/prelude-modules.el!$RESET\n"
|