From 06e10325863c1caa6a7f161718fd563de02c7184 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 24 Oct 2023 13:52:23 -0400 Subject: [PATCH] new: zimfw (replaed prezto) --- home/.chezmoiexternal.toml.tmpl | 9 -- home/dot_zpreztorc | 144 -------------------------------- home/dot_zshrc.tmpl | 60 +++++++++++-- home/private_dot_zimrc | 49 +++++++++++ 4 files changed, 103 insertions(+), 159 deletions(-) delete mode 100644 home/dot_zpreztorc create mode 100644 home/private_dot_zimrc diff --git a/home/.chezmoiexternal.toml.tmpl b/home/.chezmoiexternal.toml.tmpl index 3e370ee..bda8828 100644 --- a/home/.chezmoiexternal.toml.tmpl +++ b/home/.chezmoiexternal.toml.tmpl @@ -1,12 +1,3 @@ -[".zprezto"] - type = "git-repo" - url = "https://github.com/sorin-ionescu/prezto.git" - refreshPeriod = "168h" - [".zprezto".pull] - args = ["--recurse-submodules"] - [".zprezto".clone] - args = ["--recurse-submodules"] - {{- if eq .chezmoi.hostname "devterm" }} ["ttyscheme"] type = "git-repo" diff --git a/home/dot_zpreztorc b/home/dot_zpreztorc deleted file mode 100644 index bec0fd1..0000000 --- a/home/dot_zpreztorc +++ /dev/null @@ -1,144 +0,0 @@ -# -# Sets Prezto options. -# - -# General -# - -# Set case-sensitivity for completion, history lookup, etc. -# zstyle ':prezto:*:*' case-sensitive 'yes' - -# Color output (auto set to 'no' on dumb terminals). -zstyle ':prezto:*:*' color 'yes' - -# Set the Zsh modules to load (man zshmodules). -# zstyle ':prezto:load' zmodule 'attr' 'stat' - -# Set the Zsh functions to load (man zshcontrib). -# zstyle ':prezto:load' zfunction 'zargs' 'zmv' - -# Set the Prezto modules to load (browse modules). -# The order matters. -zstyle ':prezto:load' pmodule \ - 'environment' \ - 'terminal' \ - 'editor' \ - 'history' \ - 'directory' \ - 'spectrum' \ - 'utility' \ - 'completion' \ - 'git' \ - 'prompt' \ - 'tmux' \ - 'gpg' - -# -# Editor -# - -# Set the key mapping style to 'emacs' or 'vi'. -zstyle ':prezto:module:editor' key-bindings 'vi' - -# Auto convert .... to ../.. -# zstyle ':prezto:module:editor' dot-expansion 'yes' - -# -# Git -# - -# Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'. -# zstyle ':prezto:module:git:status:ignore' submodules 'all' - -# Disable aliases -zstyle ':prezto:module:git:alias' skip 'yes' - -# -# GNU Utility -# - -# Set the command prefix on non-GNU systems. -# zstyle ':prezto:module:gnu-utility' prefix 'g' - -# -# History Substring Search -# - -# Set the query found color. -# zstyle ':prezto:module:history-substring-search:color' found '' - -# Set the query not found color. -# zstyle ':prezto:module:history-substring-search:color' not-found '' - -# Set the search globbing flags. -# zstyle ':prezto:module:history-substring-search' globbing-flags '' - -# -# Pacman -# - -# Set the Pacman frontend. -# zstyle ':prezto:module:pacman' frontend 'yaourt' - -# -# Prompt -# - -# Set the prompt theme to load. -# Setting it to 'random' loads a random theme. -# Auto set to 'off' on dumb terminals. -zstyle ':prezto:module:prompt' theme 'peepcode' - -# -# Screen -# - -# Auto start a session when Zsh is launched in a local terminal. -# zstyle ':prezto:module:screen:auto-start' local 'yes' - -# Auto start a session when Zsh is launched in a SSH connection. -# zstyle ':prezto:module:screen:auto-start' remote 'yes' - -# -# SSH -# - -# Set the SSH identities to load into the agent. -# zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_rsa2' 'id_github' - -# -# Syntax Highlighting -# - -# Set syntax highlighters. -# By default, only the main highlighter is enabled. -# zstyle ':prezto:module:syntax-highlighting' highlighters \ -# 'main' \ -# 'brackets' \ -# 'pattern' \ -# 'cursor' \ -# 'root' -# -# Set syntax highlighting styles. -# zstyle ':prezto:module:syntax-highlighting' styles \ -# 'builtin' 'bg=blue' \ -# 'command' 'bg=blue' \ -# 'function' 'bg=blue' -# - -# -# Terminal -# - -# Auto set the tab and window titles. -zstyle ':prezto:module:terminal' auto-title 'yes' - -# -# Tmux -# - -# Auto start a session when Zsh is launched in a local terminal. -# zstyle ':prezto:module:tmux:auto-start' local 'yes' - -# Auto start a session when Zsh is launched in a SSH connection. -# zstyle ':prezto:module:tmux:auto-start' remote 'yes' diff --git a/home/dot_zshrc.tmpl b/home/dot_zshrc.tmpl index 2812027..a90753c 100644 --- a/home/dot_zshrc.tmpl +++ b/home/dot_zshrc.tmpl @@ -1,5 +1,52 @@ +# Remove older command from the history if a duplicate is to be added. +setopt HIST_IGNORE_ALL_DUPS + +# Set editor default keymap to emacs (`-e`) or vi (`-v`) +bindkey -v + +# Remove path separator from WORDCHARS. +WORDCHARS=${WORDCHARS//[\/]} + +# Disable automatic widget re-binding on each precmd. This can be set when +# zsh-users/zsh-autosuggestions is the last module in your ~/.zimrc. +ZSH_AUTOSUGGEST_MANUAL_REBIND=1 + +# Set what highlighters will be used. +# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md +ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets) + +ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim + +# Download zimfw plugin manager if missing. +if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then + if (( ${+commands[curl]} )); then + curl -fsSL --create-dirs -o ${ZIM_HOME}/zimfw.zsh \ + https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh + else + mkdir -p ${ZIM_HOME} && wget -nv -O ${ZIM_HOME}/zimfw.zsh \ + https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh + fi +fi + +# Install missing modules, and update ${ZIM_HOME}/init.zsh if missing or outdated. +if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then + source ${ZIM_HOME}/zimfw.zsh init -q +fi + +# Initialize modules. +source ${ZIM_HOME}/init.zsh + +# zsh-history-substring-search +zmodload -F zsh/terminfo +p:terminfo + +# Bind ^[[A/^[[B manually so up/down works both before and after zle-line-init +for key ('^[[A' '^P' ${terminfo[kcuu1]}) bindkey ${key} history-substring-search-up +for key ('^[[B' '^N' ${terminfo[kcud1]}) bindkey ${key} history-substring-search-down +for key ('k') bindkey -M vicmd ${key} history-substring-search-up +for key ('j') bindkey -M vicmd ${key} history-substring-search-down +unset key + srcs=( - "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" "/opt/miniconda3/etc/profile.d/conda.sh" "$HOME/.cargo/env" {{ if eq .chezmoi.hostname "rattusrattus" -}} @@ -13,11 +60,6 @@ for fp in $srcs; do fi done -BASE16_SHELL="$HOME/.config/base16-shell/" -[ -n "$PS1" ] && \ - [ -s "$BASE16_SHELL/profile_helper.sh" ] && \ - source "$BASE16_SHELL/profile_helper.sh" - alias i="ipython3" {{ if eq .chezmoi.hostname "rattusrattus" -}} @@ -57,4 +99,10 @@ function brightness_min { } # ttyscheme +{{- else }} +BASE16_SHELL="$HOME/.config/base16-shell/" +[ -n "$PS1" ] && \ + [ -s "$BASE16_SHELL/profile_helper.sh" ] && \ + source "$BASE16_SHELL/profile_helper.sh" + {{- end }} diff --git a/home/private_dot_zimrc b/home/private_dot_zimrc new file mode 100644 index 0000000..3994a86 --- /dev/null +++ b/home/private_dot_zimrc @@ -0,0 +1,49 @@ +### Modules ### + +# Sets sane Zsh built-in environment options. +zmodule environment + +# Provides handy git aliases and functions. +zmodule git + +# Applies correct bindkeys for input events. +zmodule input + +# Sets a custom terminal title. +zmodule termtitle + +# Utility aliases and functions. Adds colour to ls, grep and less. +zmodule utility + +### Prompt ### + +# Exposes to prompts how long the last command took to execute, used by asciiship. +zmodule duration-info + +# Exposes git repository status information to prompts, used by asciiship. +zmodule git-info + +# A heavily reduced, ASCII-only version of the Spaceship and Starship prompts. +zmodule asciiship + +### Completion ### + +# Additional completion definitions for Zsh. +zmodule zsh-users/zsh-completions --fpath src + +# Enables and configures smart and extensive tab completion. +# completion must be sourced after all modules that add completion definitions. +zmodule completion + +### Modules that must be initialized last ### + +# Fish-like syntax highlighting for Zsh. +# zsh-users/zsh-syntax-highlighting must be sourced after completion +zmodule zsh-users/zsh-syntax-highlighting + +# Fish-like history search (up arrow) for Zsh. +# zsh-users/zsh-history-substring-search must be sourced after zsh-users/zsh-syntax-highlighting +zmodule zsh-users/zsh-history-substring-search + +# Fish-like autosuggestions for Zsh. +zmodule zsh-users/zsh-autosuggestions