From 1ff498137e017c0c7a38f9653bd425515c59ec02 Mon Sep 17 00:00:00 2001 From: Luna Komorebi Date: Fri, 19 Apr 2024 16:05:24 +0200 Subject: [PATCH] delete ohmyzsh --- .zsh/aliases.zsh | 2 +- .zshrc | 13 ++++----- config/bat/config | 2 +- install.zsh | 68 +++++++++++++++++++++++++++++++++++++---------- 4 files changed, 63 insertions(+), 22 deletions(-) diff --git a/.zsh/aliases.zsh b/.zsh/aliases.zsh index 9ddaf74..169390e 100644 --- a/.zsh/aliases.zsh +++ b/.zsh/aliases.zsh @@ -21,7 +21,7 @@ alias \ gs='git status' \ gst='git stash' \ hx='helix' - +alias ls='ls --color=auto' alias gcl='git clone' alias history='fc -l 0' alias ytdlp='yt-dlp `xclip -o`' diff --git a/.zshrc b/.zshrc index 7670cbe..727da8a 100644 --- a/.zshrc +++ b/.zshrc @@ -18,9 +18,14 @@ else fi fi -source $ZSH/oh-my-zsh.sh +if [ -d /usr/share/zsh/plugins ] && [ -d /usr/share/zsh/plugins/zsh-autosuggestions ]; then + plugins="/usr/share/zsh/plugins" +else + plugins="$HOME/.local/share/zsh-plugins" +fi -plugins=(git docker docker-compose virtualenv) +source "$plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" +source "$plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ## History file configuration HISTFILE="$HOME/.zsh_history" @@ -53,10 +58,6 @@ if ! iscmd docker && iscmd podman; then alias c='podman-compose' fi -if iscmd google-chrome-stable; then - export BROWSER=google-chrome-stable -fi - export SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/ssh-agent.socket" for f in $OTHER/*.zsh; do diff --git a/config/bat/config b/config/bat/config index 70ff082..7fe65df 100644 --- a/config/bat/config +++ b/config/bat/config @@ -4,7 +4,7 @@ # Specify desired highlighting theme (e.g. "TwoDark"). Run `bat --list-themes` # for a list of all available themes ---theme="Catppuccin-macchiato" +#--theme="Catppuccin-macchiato" # Enable this to use italic text on the terminal. This is not supported on all # terminal emulators (like tmux, by default): diff --git a/install.zsh b/install.zsh index 77dce63..43dda2f 100755 --- a/install.zsh +++ b/install.zsh @@ -1,6 +1,12 @@ #!/usr/bin/env zsh # env, because some OSes keep zsh in /bin (I'm looking at you, Alpine) +if [ "$ZSH_EVAL_CONTEXT" = "toplevel" ]; then + echo "[!] this script is meant to be sourced" + echo "source install.zsh" > /dev/stdin + exit 1 +fi + iscmd() { command -v "$1" > /dev/null } @@ -12,27 +18,52 @@ for cmd in curl git sed install find; do fi done +set -e + +# migrate legacy +mkdir -p "$HOME"/.config/zsh +touch "$HOME"/.config/zsh/local.zsh +if [ -d "$HOME"/.zsh-custom ]; then + for file in "$HOME"/.zsh-custom/*; do + echo "# $file" >> "$HOME"/.config/zsh/local.zsh + cat "$file" >> "$HOME"/.config/zsh/local.zsh + echo "" >> "$HOME"/.config/zsh/local.zsh + rm "$file" + done + rmdir "$HOME"/.zsh-custom +fi + install() { # screw you coreutils install and your ugly messages command install -Dv $@ | grep -v removed } -if iscmd glow; then - CHANGELOG=$(glow changelog.md) +plugins_dir="$HOME/.local/share/zsh-plugins" +plugins_git=" + https://github.com/zsh-users/zsh-syntax-highlighting + https://github.com/zsh-users/zsh-autosuggestions +" + +os_id="$( . /etc/os-release && echo "$ID" )" + +if [ "$(id -u)" != 0 ]; then + if command -v doas >/dev/null; then + elevate=doas + elif command -v sudo >/dev/null; then + elevate=sudo + else + echo "[!] cannot install zsh plugins system-wide" + elevate=: + fi +fi + +if iscmd bat; then + CHANGELOG=$(bat -fp changelog.md 2> /dev/null) else CHANGELOG=$(cat changelog.md) fi cp -v .zshrc $HOME -if [ ! -d "${HOME}/.oh-my-zsh" ]; then - echo "[*] Installing OMZsh" - sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" -fi -if [ ! -d "${HOME}/.oh-my-zsh/custom/themes/powerlevel10k" ]; then - echo - echo "[*] Installing powerlevel10k" - git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/custom/themes/powerlevel10k -fi if [ -d "${HOME}/.zsh" ]; then echo echo "[*] Deleting old .zsh/" @@ -54,7 +85,6 @@ fi if [ -n "${NPM_CONFIG_PREFIX}" ]; then sed -i "s%\# export NPM_CONFIG_PREFIX=\"\"%export NPM_CONFIG_PREFIX=\"$NPM_CONFIG_PREFIX\"%g" $HOME/.zsh/env.zsh fi -cp -v .tmux.conf ~/.tmux.conf echo echo "[*] installing homedir files" @@ -76,8 +106,18 @@ find bin -type f | while read -r file; do install $file $(echo $file | sed "s|bin|$HOME/.local/bin|") done -unfunction install +for plugin in $=plugins_git; do + name="${plugin/*\//}" + if [ ! -d "$plugins_dir/$name" ]; then + echo "[*] installing $name locally" + git clone --depth=1 "$plugin" "$plugins_dir/$name" + else + echo "[+] $name installed already" + fi + done + +unfunction install +echo "" echo Important changes: echo $CHANGELOG -exec zsh