158 lines
4.4 KiB
Bash
Executable File
158 lines
4.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
RED=$(tput setaf 1)
|
|
RESET=$(tput sgr0)
|
|
GREEN=$(tput setaf 2)
|
|
BLUE=$(tput setaf 4)
|
|
BOLD=$(tput bold)
|
|
|
|
if ! command -v emacs &> /dev/null; then
|
|
echo "[${RED}ERROR${RESET}] Please install emacs first (package manager or custom build maybe?)"
|
|
exit 1
|
|
fi
|
|
|
|
echo "First you need chemacs"
|
|
if [ -d ~/.emacs.d ]; then
|
|
# Just to make the sudden output of many messages less confusing
|
|
echo "-------------"
|
|
echo "[${RED}ERROR${RESET}] .emacs.d already exists!"
|
|
|
|
echo "${BOLD}Directory listing:${RESET}"
|
|
ls -A ~/.emacs.d
|
|
|
|
echo "${BOLD}What would you like to do?${RESET}"
|
|
cat <<EOF
|
|
1. Remove dir and continue to installing chemacs to .emacs.d
|
|
2. Backup the dir in .emacs.d.bak and install chemacs [DEFAULT]
|
|
3. Skip installation of chemacs (you should make sure .emacs.d already contains chemacs!)
|
|
4. Same as above but run git pull in the directory
|
|
5. ABORT
|
|
EOF
|
|
read -p "${BOLD}1/2/3/4/5${RESET}> " option
|
|
case "$option" in
|
|
"1")
|
|
rm -rf ~/.emacs.d;;
|
|
"2"|"")
|
|
echo "Your original .emacs.d will be at .emacs.d.bak"
|
|
# TODO: check if .emacs.d.bak exists
|
|
mv ~/.emacs.d ~/.emacs.d.bak;;
|
|
"3")
|
|
echo "Skipping chemacs installation"
|
|
install_chemacs=no;;
|
|
"4")
|
|
cd ~/.emacs.d
|
|
echo "git pulling"
|
|
git pull
|
|
install_chemacs=no;;
|
|
"5")
|
|
echo "aborting :)"
|
|
exit;;
|
|
*)
|
|
echo "[${RED}ERROR${RESET}] Unknown option $option"
|
|
exit 1;;
|
|
esac
|
|
fi
|
|
if [[ $install_chemacs != "no" ]]; then
|
|
echo "> ${BLUE}Installing chemacs${RESET}"
|
|
mkdir ~/.emacs.d
|
|
cd ~/.emacs.d
|
|
git clone git@github.com:plexus/chemacs2 .
|
|
fi
|
|
read -p "${BOLD}Run emacs? [y/N]${RESET} " run
|
|
if [[ $run == "y" ]]; then
|
|
cd
|
|
emacs .config/emacsd/
|
|
fi
|
|
|
|
echo "${GREEN}Emacs and chemacs setup all done!${RESET}"
|
|
|
|
### DOOM ###
|
|
|
|
echo
|
|
echo "Now we'll setup up doom"
|
|
|
|
echo "Checking for emacs version"
|
|
VERFULL=$(emacs --version | head -n1 | sed 's/^GNU Emacs //')
|
|
VER=$(echo "$VERFULL" | grep -Eo '[[:digit:]]+[^ .]')
|
|
if (( "$VER" < 27 )); then
|
|
echo "[${RED}ERROR${RESET}] emacs version must be 27 or higher for installing doom"
|
|
echo "Current is ${BOLD}${VERFULL}${RESET}"
|
|
echo Aborting
|
|
exit
|
|
fi
|
|
|
|
read -p "${BOLD}Set up doom? [Y/n]${RESET} " option
|
|
if [[ "$option" == "n" ]]; then
|
|
echo "Exiting"
|
|
exit
|
|
fi
|
|
echo "Alright we're going to install doom. This is the part where many things could go wrong :P"
|
|
|
|
if [ -d ~/.doomemacs ]; then
|
|
# Just to make the sudden output of many messages less confusing
|
|
echo "-------------"
|
|
echo "[${RED}ERROR${RESET}] ~/.doomemacs already exists!"
|
|
|
|
echo "${BOLD}Directory listing:${RESET}"
|
|
ls -A ~/.doomemacs
|
|
|
|
echo "${BOLD}What would you like to do?${RESET}"
|
|
cat <<EOF
|
|
1. remove the dir and continue to install doomemacs
|
|
2. backup the dir and continue to install doomemacs [DEFAULT]
|
|
3. skip installation (sorta dangerous!)
|
|
4. same as above but run git pull in the dir
|
|
5. ABORT
|
|
EOF
|
|
read -p "${BOLD}1/2/3/4/5${RESET}> " option
|
|
case "$option" in
|
|
"1")
|
|
echo "Removing directory"
|
|
rm -rf ~/.doomemacs;;
|
|
"2"|"")
|
|
echo "Original dir would be at .doomemacs.bak"
|
|
mv ~/.doomemacs ~/.doomeamcs.bak;;
|
|
"3")
|
|
echo "Skipping installation!"
|
|
install_doom=no;;
|
|
"4")
|
|
cd ~/.doomemacs
|
|
echo "Running git pull"
|
|
git pull
|
|
install_doom=no;;
|
|
"5")
|
|
echo "aborting"
|
|
exit;;
|
|
*)
|
|
echo "[${RED}ERROR${RESET}] Unknown option $option"
|
|
exit 1;;
|
|
esac
|
|
fi
|
|
|
|
export DOOMDIR='/home/hedy/.config/doom'
|
|
export EMACSDIR='/home/hedy/.doomemacs'
|
|
|
|
if [[ "$install_doom" != no ]]; then
|
|
echo "> ${BLUE}Installing doom${RESET}"
|
|
mkdir ~/.doomemacs
|
|
cd ~/.doomemacs
|
|
git clone git@github.com:hlissner/doom-emacs .
|
|
|
|
echo "${BLUE}Running doom sync${RESET}"
|
|
bin/doom sync
|
|
|
|
read -p "${BOLD}Run doom install? [Y/n]${RESET} " option
|
|
if [[ "$option" != n ]]; then
|
|
echo "Running doom install with -y plus doom sync just in case"
|
|
bin/doom -y install; bin/doom sync
|
|
fi
|
|
|
|
echo "All done! Hopefully doom would work"
|
|
fi
|
|
read -p "${BOLD}Run doom emacs? [Y/n]${RESET} " option
|
|
if [[ "$option" != n ]]; then
|
|
cd ~/.config/doom
|
|
emacs --with-profile=doom .
|
|
fi
|
|
echo "Good luck, all done!"
|