Various install-script fixes
* Colour handling in zsh (& don't use "colors" as funcname) * Quote-protect -z test * Clean up verbose var-printout * git clone requires empty dir - tweak script to make it work with an existing dir * Unquote asterisks for shell-expansion when byte-compiling
This commit is contained in:
parent
fcc82c75ff
commit
d33983ce81
1 changed files with 49 additions and 38 deletions
|
@ -20,25 +20,35 @@ make_prelude_dirs () {
|
||||||
mkdir -p "$PRELUDE_INSTALL_DIR/savefile"
|
mkdir -p "$PRELUDE_INSTALL_DIR/savefile"
|
||||||
}
|
}
|
||||||
|
|
||||||
colors () {
|
colors_ () {
|
||||||
# Reset
|
case "$SHELL" in
|
||||||
RESET='\e[0m'
|
*zsh)
|
||||||
|
autoload colors && colors
|
||||||
|
eval RESET='$reset_color'
|
||||||
|
for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE
|
||||||
|
do
|
||||||
|
eval $COLOR='$fg_no_bold[${(L)COLOR}]'
|
||||||
|
eval B$COLOR='$fg_bold[${(L)COLOR}]'
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
RESET='\e[0m' # Reset
|
||||||
RED='\e[0;31m' # Red
|
RED='\e[0;31m' # Red
|
||||||
GREEN='\e[0;32m' # Green
|
GREEN='\e[0;32m' # Green
|
||||||
YELLOW='\e[0;33m' # Yellow
|
YELLOW='\e[0;33m' # Yellow
|
||||||
BLUE='\e[0;34m' # Blue
|
BLUE='\e[0;34m' # Blue
|
||||||
PURPLE='\e[0;35m' # Purple
|
PURPLE='\e[0;35m' # Magenta
|
||||||
CYAN='\e[0;36m' # Cyan
|
CYAN='\e[0;36m' # Cyan
|
||||||
WHITE='\e[0;37m' # White
|
WHITE='\e[0;37m' # White
|
||||||
|
BRED='\e[1;31m' # Bold Red
|
||||||
# Bold
|
BGREEN='\e[1;32m' # Bold Green
|
||||||
BRED='\e[1;31m' # Red
|
BYELLOW='\e[1;33m' # Bold Yellow
|
||||||
BGREEN='\e[1;32m' # Green
|
BBLUE='\e[1;34m' # Bold Blue
|
||||||
BYELLOW='\e[1;33m' # Yellow
|
BPURPLE='\e[1;35m' # Bold Magenta
|
||||||
BBLUE='\e[1;34m' # Blue
|
BCYAN='\e[1;36m' # Bold Cyan
|
||||||
BPURPLE='\e[1;35m' # Purple
|
BWHITE='\e[1;37m' # Bold White
|
||||||
BCYAN='\e[1;36m' # Cyan
|
;;
|
||||||
BWHITE='\e[1;37m' # White
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Commandline args:
|
# Commandline args:
|
||||||
|
@ -85,7 +95,7 @@ do
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
-c | --colors)
|
-c | --colors)
|
||||||
colors
|
colors_
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
-s | --source)
|
-s | --source)
|
||||||
|
@ -105,7 +115,6 @@ do
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-v | --verbose)
|
-v | --verbose)
|
||||||
echo "prelude verbose $PRELUDE_VERBOSE"
|
|
||||||
PRELUDE_VERBOSE='true';
|
PRELUDE_VERBOSE='true';
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
|
@ -118,20 +127,21 @@ done
|
||||||
|
|
||||||
VERBOSE_COLOR=$BBLUE
|
VERBOSE_COLOR=$BBLUE
|
||||||
|
|
||||||
[ -z $PRELUDE_URL ] && PRELUDE_URL="https://github.com/bbatsov/prelude.git"
|
[ -z "$PRELUDE_URL" ] && PRELUDE_URL="https://github.com/bbatsov/prelude.git"
|
||||||
[ -z "$PRELUDE_INSTALL_DIR" ] && PRELUDE_INSTALL_DIR="$HOME/.emacs.d"
|
[ -z "$PRELUDE_INSTALL_DIR" ] && PRELUDE_INSTALL_DIR="$HOME/.emacs.d"
|
||||||
|
|
||||||
if [ x$PRELUDE_VERBOSE != x ]
|
if [ x$PRELUDE_VERBOSE != x ]
|
||||||
then
|
then
|
||||||
printf "$PRELUDE_VERBOSE\n"
|
|
||||||
printf "$VERBOSE_COLOR"
|
printf "$VERBOSE_COLOR"
|
||||||
|
printf "PRELUDE_VERBOSE = $PRELUDE_VERBOSE\n"
|
||||||
printf "INSTALL_DIR = $PRELUDE_INSTALL_DIR\n"
|
printf "INSTALL_DIR = $PRELUDE_INSTALL_DIR\n"
|
||||||
printf "SOURCE_URL = $PRELUDE_URL\n"
|
printf "SOURCE_URL = $PRELUDE_URL\n"
|
||||||
if [ -n $PRELUDE_SKIP_BC ]
|
printf "$RESET"
|
||||||
|
if [ -n "$PRELUDE_SKIP_BC" ]
|
||||||
then
|
then
|
||||||
printf "Skipping bytecompilation.\n"
|
printf "Skipping bytecompilation.\n"
|
||||||
fi
|
fi
|
||||||
if [ -n $PRELUDE_INTO ]
|
if [ -n "$PRELUDE_INTO" ]
|
||||||
then
|
then
|
||||||
printf "Replacing existing config (if one exists).\n"
|
printf "Replacing existing config (if one exists).\n"
|
||||||
fi
|
fi
|
||||||
|
@ -184,17 +194,18 @@ then
|
||||||
# Existing file/directory found -> backup
|
# Existing file/directory found -> backup
|
||||||
printf " Backing up the existing config to $PRELUDE_INSTALL_DIR.pre-prelude.tar.\n"
|
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
|
tar -cf "$PRELUDE_INSTALL_DIR.pre-prelude.tar" "$PRELUDE_INSTALL_DIR" > /dev/null 2>&1
|
||||||
|
PRELUDE_INSTALL_DIR_ORIG="$PRELUDE_INSTALL_DIR"
|
||||||
# Overwrite existing?
|
# Overwrite existing?
|
||||||
if [ -n $PRELUDE_INTO ]
|
[ -n "$PRELUDE_INTO" ] || PRELUDE_INSTALL_DIR="$PRELUDE_INSTALL_DIR/prelude"
|
||||||
then
|
# Clear destination directory for git clone to work
|
||||||
|
rm -fr "$PRELUDE_INSTALL_DIR"
|
||||||
|
mkdir "$PRELUDE_INSTALL_DIR"
|
||||||
# Replace existing config
|
# Replace existing config
|
||||||
install_prelude
|
install_prelude
|
||||||
make_prelude_dirs
|
make_prelude_dirs
|
||||||
else
|
# Reinstate files that weren't replaced
|
||||||
# Install into existing config
|
tar --skip-old-files -xf "$PRELUDE_INSTALL_DIR_ORIG.pre-prelude.tar" "$PRELUDE_INSTALL_DIR" > /dev/null 2>&1
|
||||||
PRELUDE_INSTALL_DIR="$PRELUDE_INSTALL_DIR/prelude"
|
[ -n "$PRELUDE_INTO" ] || cp "$PRELUDE_INSTALL_DIR/sample/prelude-modules.el" "$PRELUDE_INSTALL_DIR"
|
||||||
install_prelude
|
|
||||||
fi
|
|
||||||
elif [ -e "$PRELUDE_INSTALL_DIR" ]
|
elif [ -e "$PRELUDE_INSTALL_DIR" ]
|
||||||
then
|
then
|
||||||
# File exist but not a regular file or directory
|
# File exist but not a regular file or directory
|
||||||
|
@ -210,16 +221,16 @@ else
|
||||||
cp "$PRELUDE_INSTALL_DIR/sample/prelude-modules.el" "$PRELUDE_INSTALL_DIR"
|
cp "$PRELUDE_INSTALL_DIR/sample/prelude-modules.el" "$PRELUDE_INSTALL_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $PRELUDE_SKIP_BC ];
|
if [ -z "$PRELUDE_SKIP_BC" ];
|
||||||
then
|
then
|
||||||
if which emacs 2>&1 > /dev/null
|
if which emacs 2>&1 > /dev/null
|
||||||
then
|
then
|
||||||
printf " Bytecompiling Prelude.\n"
|
printf " Bytecompiling Prelude.\n"
|
||||||
if [ x$PRELUDE_VERBOSE != x ]
|
if [ x$PRELUDE_VERBOSE != x ]
|
||||||
then
|
then
|
||||||
emacs -batch -f batch-byte-compile "$PRELUDE_INSTALL_DIR/core/*.el"
|
emacs -batch -f batch-byte-compile "$PRELUDE_INSTALL_DIR/core"/*.el
|
||||||
else
|
else
|
||||||
emacs -batch -f batch-byte-compile "$PRELUDE_INSTALL_DIR/core/*.el" > /dev/null 2>&1
|
emacs -batch -f batch-byte-compile "$PRELUDE_INSTALL_DIR/core"/*.el > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
printf "$YELLOW Emacs not found.$RESET Skipping bytecompilation.\n"
|
printf "$YELLOW Emacs not found.$RESET Skipping bytecompilation.\n"
|
||||||
|
|
Loading…
Reference in a new issue