From 818ddec6808b37ebe14fcf6f2801c935a47dcc2b Mon Sep 17 00:00:00 2001 From: michael Date: Sat, 14 Jan 2023 09:47:37 +0100 Subject: [PATCH] add installation script --- install.sh | 25 +++++++++++++++++++++++++ readme.md | 12 +++++++++--- zshrc | 2 +- 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100755 install.sh diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..74ddcef --- /dev/null +++ b/install.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +warn() { printf '\E[33m'; echo "$@"; printf '\E[0m'; } +error() { printf '\E[31m'; echo "$@"; printf '\E[0m'; } +success() { printf '\E[32m'; echo "$@"; printf '\E[0m'; } +abort() { warn "$@"; error "Installation aborted."; exit 1; } + +[[ -d "$HOME/.local/share/zsh" || -e "$HOME/.config/.zshrc" || -e "$HOME/.zshenv" ]] && abort ".local/share/zsh, .config/.zshrc and/or .zshenv found in $USER's home directory. Make sure these files don't already exist." + +if hash exa git nano zsh 2>/dev/null; then + success "exa git nano and zsh already installed, skipping installation." +else + ls /root >/dev/null 2>&1 || abort "No root privileges. Run this script as sudo or install exa git nano and zsh manually." + hash apt-get 2>/dev/null || abort "apt-get not found. Install exa git nano and zsh with your system's package manager." + apt-get update >/dev/null && apt-get -y install exa git nano zsh >/dev/null || abort "apt-get installation failed. After fixing the errors run 'apt-get install exa git nano zsh' or this script again." + success "Installation of exa git nano and zsh successfull." +fi + +git clone --recurse -q https://git.sdf.org/michael/zsh "$HOME/.local/share/zsh" && success "git clone successfull." || abort "Could not clone git repository." +cp "$HOME/.local/share/zsh/zshenv" "$HOME/.zshenv" +mkdir -p "$HOME/.config" +ln -fs ../.local/share/zsh/zshrc "$HOME/.config/.zshrc" +test -x /bin/zsh && chsh -s /bin/zsh && success "Zsh set as default shell." || warn "Could not set Zsh as default shell. Run chsh or edit /etc/passwd." + +success "Installation complete." diff --git a/readme.md b/readme.md index b11a1bf..e155434 100644 --- a/readme.md +++ b/readme.md @@ -1,8 +1,14 @@ -### Install [exa](https://the.exa.website) and [nano](https://www.nano-editor.org) +### Manual installation ``` git clone --recurse https://git.sdf.org/michael/zsh ~/.local/share/zsh -ln -s ../.local/share/zsh/zshrc ~/.config/.zshrc cp ~/.local/share/zsh/zshenv ~/.zshenv -usermod --shell $(which zsh) $(whoami) +mkdir -p ~/.config +ln -s ../.local/share/zsh/zshrc ~/.config/.zshrc ``` + +### Installation script +``` +curl -s https://git.sdf.org/michael/zsh/raw/branch/master/install.sh | bash +``` + ![Screenshot](https://michael.sdf.org/zsh.png) \ No newline at end of file diff --git a/zshrc b/zshrc index 764489f..47be23d 100644 --- a/zshrc +++ b/zshrc @@ -89,4 +89,4 @@ ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE=fg=024 ZSH_AUTOSUGGEST_STRATEGY=(history completion) ZSH_HIGHLIGHT_STYLES[comment]=fg=245 -(( $+commands[fortune] && $+commands[cowsay] && $+commands[lolcat] )) && fortune -s | cowsay -f small | lolcat -r -v 1 +(( $+commands[fortune] && $+commands[cowsay] && $+commands[lolcat] )) && echo && fortune -s | cowsay -f small | lolcat -r -v 1