From 5ad06b3c9e28e115b98602e26201f729f4ce1ac5 Mon Sep 17 00:00:00 2001 From: Johannes Knopp Date: Sat, 27 Jun 2026 15:06:37 +0200 Subject: [PATCH] remove oh-my-zsh --- roles/zsh/defaults/main.yaml | 9 +++++ roles/zsh/files/.zshenv | 10 +++++ roles/zsh/files/.zshrc | 72 +++++++++++++++++++----------------- roles/zsh/tasks/main.yaml | 32 ++++++++++++---- 4 files changed, 81 insertions(+), 42 deletions(-) create mode 100644 roles/zsh/defaults/main.yaml diff --git a/roles/zsh/defaults/main.yaml b/roles/zsh/defaults/main.yaml new file mode 100644 index 0000000..4eead08 --- /dev/null +++ b/roles/zsh/defaults/main.yaml @@ -0,0 +1,9 @@ +zsh_plugins_dir: "{{ home_dir }}/.zsh/plugins" + +zsh_plugins: + - name: zsh_autosuggestions + repo: https://github.com/zsh-users/zsh-autosuggestions.git + version: v0.7.1 + - name: zsh-syntax-highlighting + repo: https://github.com/zsh-users/zsh-syntax-highlighting.git + version: 0.8.0 diff --git a/roles/zsh/files/.zshenv b/roles/zsh/files/.zshenv index e4319fa..1de919d 100644 --- a/roles/zsh/files/.zshenv +++ b/roles/zsh/files/.zshenv @@ -6,3 +6,13 @@ case ":$PATH:" in *) export PATH="$PNPM_HOME:$PATH" ;; esac # pnpm end + +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +if [[ -n "$MACHINE_TYPE" && -f "$HOME/dotfiles/zsh/hosts/$MACHINE_TYPE.zsh" ]]; then + source "$HOME/dotfiles/zsh/hosts/$MACHINE_TYPE.zsh" +fi + +export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/gcr/ssh" diff --git a/roles/zsh/files/.zshrc b/roles/zsh/files/.zshrc index 6c9e12c..8ca3742 100644 --- a/roles/zsh/files/.zshrc +++ b/roles/zsh/files/.zshrc @@ -1,22 +1,43 @@ -# If you come from bash you might have to change your $PATH. -# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH +HISTFILE="$HOME/.zsh_history" +HISTSIZE=50000 +SAVEHOST=50000 +# setopt share_history # persist, and share live across open shells +setopt inc_append_history # history of session appended to HISTFILE after session ends +setopt extended_history # record timestamps +setopt hist_ignore_dups # drop a command identical to the one before it +setopt hist_ignore_space # don't record commands typed with a leading space +setopt hist_verify # let you edit a !-expansion before it runs -# Path to your Oh My Zsh installation. -export ZSH="$HOME/.oh-my-zsh" +autoload -Uz compinit +compinit -ZSH_THEME="bira" -zstyle ':omz:update' mode reminder # just remind me to update when it's time -COMPLETION_WAITING_DOTS="true" +autoload -Uz vcs_info +setopt prompt_subst -plugins=( - git - zsh-syntax-highlighting - zsh-autosuggestions - fzf-zsh-plugin -) +zstyle ':vcs_info:*' enable git +zstyle ':vcs_info:git:*' formats ' %F{yellow}‹%b› %f' +zstyle ':vcs_info:git:*' actionformats ' %F{yellow}‹%b|%a› %f' -source $ZSH/oh-my-zsh.sh +zstyle ':vcs_info:git*+set-message:*' hooks git-dirty ++vi-git-dirty() { + if [[ -n $(git status --porcelain 2>/dev/null) ]]; then + hook_com[branch]+='%F{red}●%F{yellow}' + fi +} +precmd() { vcs_info } + +PROMPT='╭─%B%(!.%F{red}.%F{green})%n@%m%f %F{blue}%~%f%b${vcs_info_msg_0_} +╰─%B%(!.#.$)%b ' +RPROMPT='%B%(?..%F{red}%? ↵%f)%b' + +expand-or-complete-with-dots() { + print -Pn '%F{red}…%f' + zle expand-or-complete + zle redisplay +} +zle -N expand-or-complete-with-dots +bindkey '^I' expand-or-complete-with-dots # Preferred editor for local and remote sessions if [[ -n $SSH_CONNECTION ]]; then @@ -31,28 +52,11 @@ for zsh_file in "$DOTFILES_ZSH_DIR"/*.zsh; do [[ -r "$zsh_file" ]] && source "$zsh_file" done - -# TODO source all files with .zsh suffix -# source ./aliases.zsh -# source ./dev_env.zsh -# source ./tools.zsh - -# TODO -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm -[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion - -if [[ -n "$MACHINE_TYPE" && -f "$HOME/dotfiles/zsh/hosts/$MACHINE_TYPE.zsh" ]]; then - source "$HOME/dotfiles/zsh/hosts/$MACHINE_TYPE.zsh" -fi - - -alias drun='docker run -it --network=host --device=/dev/kfd --device=/dev/dri --group-add=video --ipc=host --cap-add=SYS_PTRACE --security-opt seccomp=unconfined' - -export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/gcr/ssh" +ZSH_PLUGINS_DIR="$HOME/.zsh/plugins" +source "$ZSH_PLUGINS_DIR/zsh_autosuggestions/zsh-autosuggestions.zsh" +source "$ZSH_PLUGINS_DIR/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" bindkey '^H' backward-kill-word -bindkey '^R' fzf-history-widget eval "$(zoxide init zsh)" diff --git a/roles/zsh/tasks/main.yaml b/roles/zsh/tasks/main.yaml index 1210720..e6212b1 100644 --- a/roles/zsh/tasks/main.yaml +++ b/roles/zsh/tasks/main.yaml @@ -1,16 +1,32 @@ --- -- name: Install zsh +- name: Install zsh and git package: - name: zsh + name: + - zsh + - git state: present become: yes - become_user: root + # become_user: root -- name: Install oh-my-zsh - shell: | - sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" --unattended - args: - creates: "{{ home_dir }}/.oh-my-zsh" +- name: Ensure zsh plugin directory exists + file: + path: "{{ zsh_plugins_dir }}" + state: directory + mode: "0755" + +- name: Clone/checkout zsh plugins at pinned versions + git: + repo: "{{ item.repo }}" + dest: "{{ zsh_plugins_dir }}/{{ item.name }}" + version: "{{ item.version }}" + update: true + loop: "{{ zsh_plugins }}" + +# - name: Install oh-my-zsh +# shell: | +# sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" --unattended +# args: +# creates: "{{ home_dir }}/.oh-my-zsh" - name: Symlink .zshenv file: