diff --git a/.zshrc b/.zshrc index b6218de..91d0069 100644 --- a/.zshrc +++ b/.zshrc @@ -1,135 +1,31 @@ -# --- 1. System Erkennung & Bootstrap Logik --- - -# Funktion zur Erkennung des OS -get_os_info() { - if [ -f /etc/os-release ]; then - . /etc/os-release - OS_ID=$ID - OS_LIKE=$ID_LIKE - elif [[ "$OSTYPE" == "darwin"* ]]; then - OS_ID="macos" - elif [[ "$OSTYPE" == "freebsd"* ]]; then - OS_ID="freebsd" - elif [ -d "/data/data/com.termux" ]; then - OS_ID="termux" - fi -} -get_os_info - -# Automatisches Setup der Config-Dateien (Fastfetch & Neovim) -setup_configs() { - # Fastfetch Config erstellen - if [ ! -f ~/.config/fastfetch/fastfetch.jsonc ]; then - echo "--> Erstelle Fastfetch Config..." - mkdir -p ~/.config/fastfetch - cat < ~/.config/fastfetch/fastfetch.jsonc -{ - "\$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", - "logo": { "type": "small", "position": "top", "padding": { "top": 1, "bottom": 0 } }, - "display": { "separator": " -> ", "color": { "separator": "1" }, "key": { "type": "both", "paddingLeft": 0 } }, - "modules": [ - { "type": "custom", "format": "┌──────── {#1}System Information{#} ────────┐" }, - { "type": "os", "key": " OS ", "keyColor": "red" }, - { "type": "host", "key": " Machine", "keyColor": "green" }, - { "type": "kernel", "key": " Kernel ", "keyColor": "magenta" }, - { "type": "uptime", "key": " Uptime ", "keyColor": "red" }, - { "type": "shell", "key": " Shell ", "keyColor": "cyan" }, - { "type": "cpu", "key": " CPU ", "keyColor": "yellow" }, - { "type": "memory", "key": " Memory ", "keyColor": "magenta" }, - { "type": "swap", "key": " Swap ", "keyColor": "magenta" }, - { "type": "custom", "format": "└──────────────────────────────────────┘" } - ] -} -EOF - fi - -# Neovim Config erstellen - if [ ! -f ~/.config/nvim/init.lua ]; then - echo "--> Erstelle Neovim Config..." - mkdir -p ~/.config/nvim - cat < ~/.config/nvim/init.lua --- True Color Support erzwingen -vim.opt.termguicolors = true - --- Maus deaktivieren -vim.opt.mouse = "" - --- Einrückung: 4 Leerzeichen -vim.opt.shiftwidth = 4 -vim.opt.tabstop = 4 -vim.opt.expandtab = true - --- Transparenz erzwingen (Normaler Text & UI-Elemente) -vim.cmd[[highlight Normal guibg=NONE ctermbg=NONE]] -vim.cmd[[highlight NonText guibg=NONE ctermbg=NONE]] -vim.cmd[[highlight SignColumn guibg=NONE ctermbg=NONE]] -vim.cmd[[highlight EndOfBuffer guibg=NONE ctermbg=NONE]] - --- Zeilennummern & Cursorline -vim.opt.number = true -vim.opt.relativenumber = false -vim.opt.cursorline = true - --- FARBEN & HINTERGRÜNDE (Kein Grau mehr) --- LineNr: Inaktive Nummern (Hellgrau, Hintergrund transparent) -vim.api.nvim_set_hl(0, 'LineNr', { fg = '#a0a0a0', bg = 'NONE' }) - --- CursorLineNr: Aktuelle Zeilennummer (Neon-Gelb, Hintergrund transparent) -vim.api.nvim_set_hl(0, 'CursorLineNr', { fg = '#ffcc00', bg = 'NONE', bold = true }) - --- CursorLine: Der Balken der aktiven Zeile (Hintergrund komplett weg) -vim.api.nvim_set_hl(0, 'CursorLine', { bg = 'NONE', ctermbg = 'NONE' }) -EOF - fi -} - -install_missing_packages() { - echo "--> Komponenten fehlen. Starte Bootstrap für $OS_ID..." - local pkgs=(git neovim fastfetch eza zsh curl) - local s=""; (( $+commands[sudo] )) && s="sudo" - - case "$OS_ID" in - arch|cachyos) - $s pacman -Syu --needed --noconfirm "${pkgs[@]}" shadow - ;; - alpine) - $s apk add "${pkgs[@]}" ncurses-terminfo-base shadow - ;; - debian|ubuntu|kali) - $s apt update - # In Debian heißt das Paket 'passwd' oder einfach nur 'shadow' (falls nötig) - $s apt install -y git neovim fastfetch eza zsh curl - ;; - fedora|rhel) - $s dnf install -y "${pkgs[@]}" shadow-utils - ;; - termux) - pkg install -y git neovim fastfetch eza zsh curl - ;; - freebsd) - $s pkg install -y git neovim fastfetch eza zsh curl - ;; - esac - setup_configs -} - -# Bootstrap Trigger: Wenn eza oder fastfetch fehlen -if ! command -v fastfetch &> /dev/null || ! command -v eza &> /dev/null; then - install_missing_packages -fi - -# --- 2. ZSH Plugins & Theme (Zinit) --- - -(( $+commands[fastfetch] )) && sleep 0.1 && fastfetch --config ~/.config/fastfetch/fastfetch.jsonc - +# 1. P10k Instant Prompt (MUSS GANZ OBEN STEHEN) 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 +# 2. OS Info +if [ -f /etc/os-release ]; then + . /etc/os-release + OS_ID=$ID +fi + +# Environment +export EDITOR='nvim' +export VISUAL='nvim' +export TERM='xterm-256color' + +# Entferne das '/' aus der Definition eines Wortes +WORDCHARS='*?_-.[]~=&;!#$%^(){}<>' + +# 3. Zinit Setup ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git" -[ ! -d "$ZINIT_HOME" ] && mkdir -p "$(dirname $ZINIT_HOME)" && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" +if [ ! -d "$ZINIT_HOME" ]; then + mkdir -p "$(dirname $ZINIT_HOME)" + git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" +fi source "${ZINIT_HOME}/zinit.zsh" +# 4. Plugins zinit ice depth=1; zinit light romkatv/powerlevel10k zinit light zsh-users/zsh-syntax-highlighting zinit light zsh-users/zsh-completions @@ -139,25 +35,33 @@ zinit load 'zsh-users/zsh-history-substring-search' autoload -Uz compinit && compinit zinit cdreplay -q + +# 5. Theme & Fastfetch [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh +# Fastfetch erst nach dem Prompt-Setup aufrufen +(( $+commands[fastfetch] )) && fastfetch --config ~/.config/fastfetch/config.jsonc -# --- 3. Aliases & Keybindings --- +# --- History & Options --- +HISTSIZE=5000 +HISTFILE=~/.zsh_history +SAVEHIST=$HISTSIZE +setopt appendhistory sharehistory hist_ignore_space hist_ignore_all_dups +setopt hist_save_no_dups hist_ignore_dups hist_find_no_dups +setopt autocd auto_param_slash globdots +# --- Aliases & Update Script --- alias c='clear' alias x='exit' -alias l='eza -lagh --icons --group-directories-first' + +# Check ob eza installiert ist, sonst ls fallback +if (( $+commands[eza] )); then + alias l='eza -lagh --group-directories-first' +else + alias l='ls -lah --color=always --group-directories-first' +fi alias yay='yay --noconfirm' -alias yayold='yay' -# Keybindings -bindkey -e -bindkey "^[[1;5C" forward-word -bindkey "^[[1;5D" backward-word -bindkey "^[[3~" delete-char -bindkey '^[[A' history-substring-search-up -bindkey '^[[B' history-substring-search-down - -# --- 4. Das Ultimative Update Script --- +# --- Update Script --- update_system() { # Hilfsfunktion für Flatpak (nur ausführen wenn installiert) @@ -231,7 +135,10 @@ update_system() { } alias u='update_system' -# Environment -export EDITOR='nvim' -export VISUAL='nvim' -WORDCHARS='*?_-.[]~=&;!#$%^(){}<>' \ No newline at end of file +# Keybindings +bindkey -e +bindkey "^[[1;5C" forward-word +bindkey "^[[1;5D" backward-word +bindkey "^[[3~" delete-char +bindkey '^[[A' history-substring-search-up +bindkey '^[[B' history-substring-search-down \ No newline at end of file