Skip to content

Instantly share code, notes, and snippets.

@andru255
Last active February 5, 2018 04:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andru255/eaa11e63e368ff850343 to your computer and use it in GitHub Desktop.
Save andru255/eaa11e63e368ff850343 to your computer and use it in GitHub Desktop.
Single bash to install/uninstall a specific version of emacs editor (24.5)

IMPORTANT NOTE: Only tested under linux/debian 7.0

For use this bash it needs run in the $HOME folder and execute this command:

~ sudo chmod +x install_emacs_24.5.sh

Then:

~ ./install_emacs_26.sh

or:

~ bash install_emacs_26.sh

If pass problems in the instalation can be pass the param "--uninstall" for remove the source folder and the program

~ bash install_emacs_26.sh --uninstall

#!/bin/bash
#Script to install emacs 26 from the emacs mirror hosted in github
version="install_emacs_26.0.91"
url="https://github.com/emacs-mirror/emacs/archive/$version.tar.gz"
uninstall_flag=$1
function main {
if [[ $uninstall_flag == "--uninstall" ]]; then
uninstall_emacs
else
install_dependencies
install_emacs
install_success
fi
}
function install_dependencies {
sudo apt-get install build-essential \
texinfo libx11-dev libxpm-dev libjpeg-dev libpng-dev \
libgif-dev libtiff-dev libgtk2.0-dev libncurses-dev \
autoconf automake
}
function install_emacs {
echo "Go $HOME"
cd $HOME
echo "Creating the emacs folder..."
mkdir emacs
echo "Go to the created emacs folder..."
cd $HOME/emacs
echo "Invoque and untar from the mirror hosted in github"
curl -L $url | tar zx
echo "Go to to emacs-$version folder"
cd "emacs-$version"
echo "Executing the autogen.sh"
./autogen.sh
echo "Executing the default settings"
./configure --with-gnutls=no
echo "Making the installer"
make
echo "Execute the installer with superuser mode, "
echo "basically the binary copy to the path /usr/local/bin"
sudo make install
echo "done!"
}
function uninstall_emacs {
read -p "Are you sure to uninstall emacs? (y/n)" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Go to source folder"
cd "$HOME/emacs/emacs-$version"
echo "uninstalling..."
sudo make uninstall
cd $HOME
sudo rm -fr "$HOME/emacs/emacs-$version"
echo "done."
else
exit 1
fi
}
function install_success {
echo "emacs has been successfully installed :D"
emacs --version
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment