Skip to content

Improvements for zimrc #1

@hurricanehrndz

Description

@hurricanehrndz

I really enjoyed your zimrc blog post, and I was able to build upon it, so I thought I would shared

# cache and compile output of a binary init cmd
# see: https://github.com/zimfw/zimfw/issues/528
zmodule-eval() {
  local -r ztarget=${2//[^[:alnum:]]/-}.zsh
  zmodule custom-${1} --use mkdir --if-command ${1} \
      --cmd "if [[ ! {}/${ztarget} -nt \${commands[${1}]} ]]; then ${2} >! {}/${ztarget}; zcompile -UR {}/${ztarget}; fi" \
      --source ${ztarget}
}

zmodule-eval-with-defer() {
  local -r ztarget=${2//[^[:alnum:]]/-}.zsh
  zmodule custom-${1} --use mkdir --if-command ${1} \
      --cmd "if [[ ! {}/${ztarget} -nt \${commands[${1}]} ]]; then ${2} >! {}/${ztarget}; zcompile -UR {}/${ztarget}; fi && zsh-defer source {}/${ztarget}"
}
# compile personal settings
zmodule $ZDOTDIR/modules --cmd ":"
# Settings for modules
zmodule my-zstyles --use mkdir --cmd "source $ZDOTDIR/modules/zstyles.zsh"

# Exports
zmodule my-exports --use mkdir --cmd "source $ZDOTDIR/modules/exports.zsh"

# compile zephyr plugins
zmodule mattmc3/zephyr --cmd ":"

# Sets sane Zsh built-in environment options.
zmodule zephyr-environment --use mkdir --cmd "source $ZIM_HOME/modules/zephyr/plugins/environment/environment.plugin.zsh"
# Override and fill in the gaps of the default keybinds
zmodule zephyr-editor --use mkdir --cmd "source $ZIM_HOME/modules/zephyr/plugins/editor/editor.plugin.zsh"
zmodule my-editor --use mkdir --cmd "source $ZDOTDIR/modules/editor.zsh"
# Load and initialize the built-in zsh history system
zmodule zephyr-history --use mkdir --cmd "source $ZIM_HOME/modules/zephyr/plugins/history/history.plugin.zsh"
# Set options and aliases related to the dirstack and filesystem
zmodule zephyr-directory --use mkdir --cmd "source $ZIM_HOME/modules/zephyr/plugins/directory/directory.plugin.zsh"
# Make terminal things more colorful
zmodule zephyr-color --use mkdir --cmd "source $ZIM_HOME/modules/zephyr/plugins/color/color.plugin.zsh"

# Performance tuning
zmodule romkatv/zsh-defer

# Aliases and better defaults for exa
zmodule my-aliases --use mkdir --cmd "source $ZDOTDIR/modules/aliases.zsh"
zmodule exa
# Configures fzf for fuzzy command-line history and file search.
zmodule fzf
# Git convenience with fzf integration.
zmodule wfxr/forgit

#
# Prompt
#

# Exposes how long the last command took to run to prompts.
zmodule duration-info
# Exposes git repository status information to prompts.
zmodule git-info
# A heavily reduced, ASCII-only version of the Spaceship and Starship prompts.
zmodule asciiship

# Additional completion definitions for Zsh.
zmodule zsh-users/zsh-completions --fpath src
# Enables and configures smart and extensive tab completion.
zmodule zephyr-completion --use mkdir --cmd "source $ZIM_HOME/modules/zephyr/plugins/completion/completion.plugin.zsh"

# Replace zsh's default completion selection menu with fzf.
# Must be last plugin to bind to TAB
zmodule Aloxaf/fzf-tab --cmd 'zsh-defer source {}/fzf-tab.zsh'

# aactivator
zmodule-eval-with-defer 'aactivator' 'aactivator init'

#
# Modules that must be initialized last
#
zmodule zsh-users/zsh-syntax-highlighting --cmd 'zsh-defer source {}/zsh-syntax-highlighting.zsh'
zmodule zsh-users/zsh-autosuggestions --cmd 'zsh-defer source {}/zsh-autosuggestions.zsh'

# cleanup
unfunction zmodule-eval
unfunction zmodule-eval-with-defer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions