diff options
author | jakobst1n <jakob.stendahl@outlook.com> | 2021-01-17 22:08:13 +0100 |
---|---|---|
committer | jakobst1n <jakob.stendahl@outlook.com> | 2021-01-17 22:08:13 +0100 |
commit | c251b6c2e37aebb5738a890da904fc3b6abac9a0 (patch) | |
tree | 68e8f1f4b971018a21e8dc75f8bb4709bd062966 | |
parent | 579c779c3b8db3d2d507ccdde0ccff6cd4192ceb (diff) | |
download | dotfiles-c251b6c2e37aebb5738a890da904fc3b6abac9a0.tar.gz dotfiles-c251b6c2e37aebb5738a890da904fc3b6abac9a0.zip |
Share more code between setups
-rwxr-xr-x | install.sh | 64 | ||||
-rw-r--r-- | install/install_arch.sh | 70 | ||||
-rwxr-xr-x | install/install_fedora.sh | 70 | ||||
-rwxr-xr-x | install/install_linux.sh (renamed from install/install_debian.sh) | 2 |
4 files changed, 44 insertions, 162 deletions
@@ -1,26 +1,48 @@ -#!/bin/sh +#!/bin/bash -echo "Install the dependencies and symlink the dotfiles" -tput setaf 4 -echo "Install on wich system? Enter either \"mac\", \"debian\", \"arch\", \"fedora\":" -tput setaf 3 -printf "> " -read platform -printf "\n" -tput sgr0 - -if [ $platform == "mac" ]; then - ./install/install_mac.sh +if [ "$EUID" -eq 0 ]; then + echo "Please don't run this as root, let sudo handle privilege escalation" + exit 1 fi - -if [ $platform == "arch" ]; then - ./install/install_arch.sh +if ! command -v sudo &> /dev/null; then + echo "Could not find sudo, please make sure it is installed and set up correctly." + exit fi -if [ $platform == "debian" ]; then - ./install/install_debian.sh -fi +case "$OSTYPE" in + darwin*) + export INSTALLER_PM="brew" + echo "Detected your OS as \"mac\"." + ./install/install_mac.sh + ;; + linux*) + echo "I detected that you are running linux, please enter your distro." + tput setaf 4 + echo "Please enter: \"arch\", \"fedora\" or \"debian\"" + tput setaf 3 + printf "> " + read distro + printf "\n" + tput sgr0 -if [ $platform == "fedora" ]; then - ./install/install_fedora.sh -fi + if [ $distro == "arch" ]; then + export INST_PM="sudo packman -S" + elif [ $distro == "debian" ]; then + export INST_PM="sudo apt-get -y install" + elif [ $distro == "fedora" ]; then + export INST_PM="sudo dnf -qy install" + else + echo "Unknown distro." + echo "If you know what os you have, you can run the install script manually." + echo "first run `export INST_PM=\"<sudo package-manager>\"` to indicate the package manager to the install script." + exit 1 + fi + + ./install/install_linux.sh + ;; + *) + echo "Unkown OS..." + echo "If you know what os you have, you can run the install script manually." + echo "first run `export INST_PM=\"<sudo package-manager>\"` to indicate the package manager to the install script." + ;; +esac diff --git a/install/install_arch.sh b/install/install_arch.sh deleted file mode 100644 index 3bd9d42..0000000 --- a/install/install_arch.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash
-
-function dlgYN() {
- tput sc
- tput setaf 4
- printf "$1 (y/n)? "
- while :
- do
- read -n 1 -p "" YNQuestionAnswer
- if [[ $YNQuestionAnswer == "y" ]]; then
- tput rc; tput el
- printf "$1?: \e[0;32mYes\e[0m\n"
- tput sc
- eval $2=1 # Set parameter 2 of input to the return value
- break
- elif [[ $YNQuestionAnswer == "n" ]]; then
- tput rc; tput el
- printf "$1?: \e[0;31mNo\e[0m\n"
- eval $2=0 # Set parameter 2 of input to the return value
- break
- fi
- done
-}
-
-dlgYN "> Install \"Highlight, atool, w3m, mediainfo, vim, git\"" res
-if [ $res -eq 1 ]; then
- tput sc
- sudo pacman -S install highlight atool w3m mediainfo curl zsh vim git python3-pip tmux
- tput rc; tput ed
-fi
-
-dlgYN "> Install Oh-My-Zsh" res
-if [ $res -eq 1 ]; then
- tput sc
- sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
-
- # Zsh-autosuggestions
- git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
- # Zsh-syntax-highlighting
- git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
-
- tput rc; tput ed
-fi
-
-dlgYN "> Install Powerline and Powerlevel10k" res
-if [ $res -eq 1 ]; then
- tput sc
- pip3 install pygments
- pip3 install powerline-status
- git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
- tput rc; tput ed
-fi
-
-dlgYN "> Create symlinks" res
-if [ $res -eq 1 ]; then
- CWD=$(pwd)
- tput sc
- ln -isf "$CWD/bin" ~/bin
- ln -isf "$CWD/linux/tmux.conf" ~/.tmux.conf
- ln -isf "$CWD/Common/zshrc" ~/.zshrc
- ln -isf "$CWD/Common/vimrc" ~/.vimrc
- ln -isf "$CWD/Common/vim" ~/.vim
- ln -isf "$CWD/Common/p10k.zsh" ~/.p10k.zsh
- tput rc; tput ed
-fi
-
-tput setaf 3
-echo "\nPlease install the font Roboto mono nerd, and enable it in your terminal."
-echo "\nPlease run ':PlugInstall' in vim"
-tput sgr0
diff --git a/install/install_fedora.sh b/install/install_fedora.sh deleted file mode 100755 index 83cfc48..0000000 --- a/install/install_fedora.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash - -function dlgYN() { - tput sc - tput setaf 4 - printf "$1 (y/n)? " - while : - do - read -n 1 -p "" YNQuestionAnswer - if [[ $YNQuestionAnswer == "y" ]]; then - tput rc; tput el - printf "$1?: \e[0;32mYes\e[0m\n" - tput sc - eval $2=1 # Set parameter 2 of input to the return value - break - elif [[ $YNQuestionAnswer == "n" ]]; then - tput rc; tput el - printf "$1?: \e[0;31mNo\e[0m\n" - eval $2=0 # Set parameter 2 of input to the return value - break - fi - done -} - -dlgYN "> Install \"Highlight, atool, w3m, mediainfo, vim, git\"" res -if [ $res -eq 1 ]; then - tput sc - sudo dnf -qy install highlight atool w3m mediainfo curl zsh vim git python3-pip zsh tmux - tput rc; tput ed -fi - -dlgYN "> Install Oh-My-Zsh" res -if [ $res -eq 1 ]; then - tput sc - sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" - - # Zsh-autosuggestions - git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions - # Zsh-syntax-highlighting - git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting - - tput rc; tput ed -fi - -dlgYN "> Install Powerline and Powerlevel10k" res -if [ $res -eq 1 ]; then - tput sc - pip3 install pygments - pip3 install powerline-status - git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k - tput rc; tput ed -fi - -dlgYN "> Create symlinks" res -if [ $res -eq 1 ]; then - CWD=$(pwd) - tput sc - ln -isf "$CWD/bin" ~/bin - ln -isf "$CWD/linux/tmux.conf" ~/.tmux.conf - ln -isf "$CWD/Common/zshrc" ~/.zshrc - ln -isf "$CWD/Common/vimrc" ~/.vimrc - ln -isf "$CWD/Common/vim" ~/.vim - ln -isf "$CWD/Common/p10k.zsh" ~/.p10k.zsh - tput rc; tput ed -fi - -tput setaf 3 -echo "\nPlease install the font Roboto mono nerd, and enable it in your terminal." -echo "\nPlease run ':PlugInstall' in vim" -tput sgr0 diff --git a/install/install_debian.sh b/install/install_linux.sh index 1316724..7355bdd 100755 --- a/install/install_debian.sh +++ b/install/install_linux.sh @@ -25,7 +25,7 @@ function dlgYN() { dlgYN "> Install \"Highlight, atool, w3m, mediainfo, vim, git\"" res if [ $res -eq 1 ]; then tput sc - sudo apt -y install highlight atool w3m mediainfo curl zsh vim git python3-pip tmux + $INST_PM highlight atool w3m mediainfo curl zsh vim git python3-pip zsh tmux tput rc; tput ed fi |