This commit is contained in:
Jules 2023-11-29 02:37:50 +01:00
commit ce9edb03b6

137
my_zsh.sh Executable file
View File

@ -0,0 +1,137 @@
#!/bin/bash
# Created by hmike
# https://gitlab.com/whitemike00/scripts/-/blob/master/install_zsh-omz.sh
############################ INSTALL <----------------------------*******************
# curl https://gist.githubusercontent.com/balmacefa/87818833c9ada45af09b5f8ac0b179a7/raw/908705adea903a1d34e999241fcf1e39c3c3f172/install_OhMyZSH_PowerLevel10k.sh | sh
# mod by: @balmacefa
set -o errexit
set -o pipefail
APPS="zsh git curl wget unzip"
OS=$(source /etc/os-release && echo "${ID}")
DATE=$(date '+%d.%m.%Y_%Hh%M')
# Installation of packages
case ${OS} in
"debian" | "ubuntu" | "linuxmint" | "pop")
sudo apt update && sudo apt install $APPS -y
;;
"arch" | "manjaro")
sudo pacman -Sy $APPS --noconfirm
;;
"fedora" | "centos" | "rhel")
sudo dnf install $APPS -y
;;
"solus")
sudo eopkg install $APPS -y
;;
*)
echo -e "\e[31mSystem can't be defined."
exit
;;
esac
# Fonts installlation
if [[ ! -d /usr/share/fonts/hack ]]; then
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/Hack.zip -O "${HOME}"/hack.zip
unzip "${HOME}"/hack.zip -d "${HOME}"/hack && rm "$HOME"/hack.zip
find "${HOME}"/hack/ -iname "*Windows*" -exec rm {} \;
sudo mkdir -p /usr/share/fonts/hack
sudo mv "${HOME}"/hack/* /usr/share/fonts/hack
rmdir "${HOME}"/hack
fi
# Change default shell
sudo chsh -s /usr/bin/zsh "${USER}"
# Backup old zshrc
if [[ -f "${HOME}"/.zshrc ]]; then
cp "${HOME}"/.zshrc "${HOME}"/.zshrc.backup_"${DATE}"
elif [[ ! -f "${HOME}"/.zshrc ]]; then
touch "${HOME}"/.zshrc
fi
# Backup old installation of oh-my-zsh
if [[ -d "${HOME}"/.oh-my-zsh ]]; then
mv "${HOME}"/.oh-my-zsh "${HOME}"/.oh-my-zsh.backup_"${DATE}"
fi
# Installation OhMyZsh + powerlevel10k + plugins
git clone https://github.com/ohmyzsh/ohmyzsh.git "${HOME}"/.oh-my-zsh
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
echo '# Path to your oh-my-zsh installation
export ZSH="$HOME/.oh-my-zsh"
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block, everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Fix slowness of pastes with zsh-syntax-highlighting.zsh
pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
zle -N self-insert url-quote-magic
}
pastefinish() {
zle -N self-insert $OLD_SELF_INSERT
}
zstyle :bracketed-paste-magic paste-init pasteinit
zstyle :bracketed-paste-magic paste-finish pastefinish
source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
export ZSH_HIGHLIGHT_MAXLENGTH="60"
# ZSH Theme
ZSH_THEME="powerlevel10k/powerlevel10k"
# Uncomment the following line to use case-sensitive completion.
CASE_SENSITIVE="off"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
DISABLE_AUTO_UPDATE="off"
# Uncomment the following line to automatically update without prompting.
DISABLE_UPDATE_PROMPT="off"
# Uncomment the following line to change how often to auto-update (in days).
export UPDATE_ZSH_DAYS=15
# Uncomment the following line if pasting URLs and other text is messed up.
DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable colors in ls.
DISABLE_LS_COLORS="off"
# Uncomment the following line to disable auto-setting terminal title.
DISABLE_AUTO_TITLE="off"
# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"
# History time stamp
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
HIST_STAMPS="dd.mm.yyyy"
# ZSH plugins
plugins=(
git
zsh-autosuggestions
zsh-completions
zsh-syntax-highlighting)
source $ZSH/oh-my-zsh.sh
# User configuration
export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='vim'
else
export EDITOR='vim'
fi
# Compilation flags
export ARCHFLAGS="-arch x86_64"
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh' > "${HOME}"/.zshrc
echo -e "\e[32mInstallation is finished you must relaunch your $USER session to apply the configurations.\n\e[32mTo get display of special characters, you must set up fonts in your terminal options.\e[0m"