#!/usr/bin/bash cd ~ # get os_id for zsh installtion if [[ -r /etc/os-release ]]; then os_id=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"') fi # check if zsh shell installed if [[ ! -f "/usr/bin/zsh" || ! -f "/bin/zsh" ]]; then case $os_id in *arch*|*manjaro*) sudo pacman -S zsh --noconfirm ;; *debian*|*ubuntu*|*raspbian*) sudo apt install zsh -y ;; *fedora*) sudo dnf install zsh -y ;; *) esac fi # check if oh my zsh installed if [ ! -d "~/.oh-my-zsh" ]; then sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended fi # install powerlevel10k if [ ! -d "~/.oh-my-zsh/custom//themes/powerlevel10k" ]; then git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k fi # install powerlevel10k theme & alias plugin if [ ! -d "~/.oh-my-zsh/custom/plugins/rainbow-alias" ]; then mkdir -p ~/.oh-my-zsh/custom/plugins/rainbow-alias/ curl -o ~/.oh-my-zsh/custom/plugins/rainbow-alias/rainbow-alias.plugin.zsh https://gitea.mkex.de/blacknet76/rainbow-zsh-theme/raw/branch/master/rainbow-alias.plugin.zsh fi curl -o ~/.p10k.zsh https://gist.githubusercontent.com/blacknet76/3da6dd1b6f164ab1843fed097d209508/raw/c34fb17603bc61f2653b192a5df938d5e9d077d5/.p10k.zsh # install needfull plugins if [ ! -d "~/.oh-my-zsh/custom/plugins/zsh-autosuggestions" ]; then git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions fi if [ ! -d "~/.oh-my-zsh/custom/plugins/zsh-history-substring-search" ]; then git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search fi if [ ! -d "~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting" ]; then git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting fi # set powerlevel10k values if [ -z $(sed -n '/Enable Powerlevel10k instant prompt/=' ~/.zshrc) ]; then sed -i '1 i\# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.\n# Initialization code that may require console input (password prompts, [y/n]\n# confirmations, etc.) must go above this block; everything else may go below.\nif [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then\n source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"\nfi\n' ~/.zshrc fi sed -i.bak 's/^[[:space:]]*ZSH_THEME=.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/' ~/.zshrc # add neefull plugins if [ -z $(sed -n '/rainbow-alias/=' ~/.zshrc) ]; then sed -i -e 's/\(^plugins=([^)]*\)/\1 rainbow-alias/' ~/.zshrc fi if [ -z $(sed -n '/zsh-autosuggestions/=' ~/.zshrc) ]; then sed -i -e 's/\(^plugins=([^)]*\)/\1 zsh-autosuggestions/' ~/.zshrc fi if [ -z $(sed -n '/zsh-history-substring-search/=' ~/.zshrc) ]; then sed -i -e 's/\(^plugins=([^)]*\)/\1 zsh-history-substring-search/' ~/.zshrc fi if [ -z $(sed -n '/zsh-syntax-highlighting/=' ~/.zshrc) ]; then sed -i -e 's/\(^plugins=([^)]*\)/\1 zsh-syntax-highlighting/' ~/.zshrc fi if [ -z $(sed -n '/source ~\/.p10k.zsh/=' ~/.zshrc) ]; then sed -i '$a# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.\n[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh\n' ~/.zshrc fi echo "Change Shell to zsh when you want!" echo "chsh -s $(which zsh)"