Giter VIP home page Giter VIP logo

zpmod's Introduction

Module: zpmod

🍎 Build (MacOS) 🐧 Build (Linux)


The module is a binary Zsh module (think about zmodload Zsh command, it's that topic) which transparently and automatically compiles sourced scripts. Many plugin managers do not offer compilation of plugins, the module is a solution to this. Even if a plugin manager does compile plugin's main script (like Zi does).

Installation

Without Zi

Install just the standalone binary which can be used with anyother plugin manager.

Note This script can be used with most plugin managers and Zi is not required.

sh <(curl -fsSL https://raw.githubusercontent.com/z-shell/zpmod/main/Scripts/install.sh)

This script will display what to add to ~/.zshrc (2 lines) and show usage instructions.

With Zi

Note Zi users can build the module by issuing following command instead of running above build.sh script.

zi module build

This command will compile the module and display instructions on what to add to ~/.zshrc.

Measuring Time of sources

Besides the compilation-feature, the module also measures duration of each script sourcing. Issue zpmod source-study after loading the module at top of ~/.zshrc to see a list of all sourced files with the time the sourcing took in milliseconds on the left. This feature allows to profile the shell startup. Also, no script can pass-through that check and you will obtain a complete list of all loaded scripts, like if Zshell itself was investigating this. The list can be surprising.

Debugging

To enable debug messages from the module set:

typeset -g ZI_MOD_DEBUG=1

zpmod's People

Contributors

dependabot[bot] avatar ss-o avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

zpmod's Issues

[docs]: How to install the traditional way?

Description

I don't want to use zi (because zpmod would be the only thing I'd use it for). And even less so sh <(curl ...). There are multiple reasons against the latter.

  • It doesn't provide system-wide installation of the plugin.
  • It's not possible to integrate this with standard package managers, for example to build a .deb package.
  • There have been far to many security exploits based on this (see for example https://0x46.net/thoughts/2019/04/27/piping-curl-to-shell/ for a discussion).
  • The auto-update part in the install script also is problematic from a sysadmin / security perspective

So I tried:

  • Checking out the repo.
  • ./configure --enable-cflags='-g -Wall -Wextra -O3' --disable-gdbm --without-tcsetpgrp && make -j$(nproc) (it seems that make runs the configure script all over again).
  • module_path+=($PWD/Src/zi) ; zmodload zpmod

But at this point I'm not able to see of/how zpmod is actually running. And where it stores the compiled files. I tried creating directory ~/.zi, but it's not being populated. And zpmod source-study -l shows loading time of some files in the order of 100ms, which I guess means they're not being compiled.


BTW, the links in the bug templates to Contributing Guidelines and Contributor C. Code of Conduts are broken.

Select the area that is associated with this issue.

No response

Self-service

  • I'd be willing to address this documentation request myself.

Have you read the Contributing Guidelines?

Are you familiar with the Contributor Covenant Code of Conduct?

Contact Details

No response

[bug]: (eval):ZIModule_:1: can't write zwc file: /proc/self/fd/15.zwc

Environment

Fedora Workstation 39

Reproduction steps

  1. Install zpmod acording to the "Without Zi" section
  2. Add the two lines at the top of $ZDOTDIR/.zshrc according to the instructions

Expected behavior

zpmod operates normally according to README.md

Current behavior

Upon opening a new terminal session, the following message appears: "(eval):ZIModule_:1: can't write zwc file: /proc/self/fd/15.zwc"

Code snippet

module_path+=( "/home/konstantink/.zi/zmodules/zpmod/Src" )
zmodload zi/zpmod

# zsh plugin management functions
export ZPLUGINDIR="$ZDOTDIR/plugins"
getplugin () {
    url=$1
    reponame=$(echo "$url" | frawk -F/ '{print $NF}' | sed -e 's/.git$//')
    git clone "$url" "$ZPLUGINDIR/$reponame"
}

loadplugin () {
    for name in "$@"; do
        zplugin="$ZPLUGINDIR/$name/$name.plugin.zsh"
        [[ -f "$zplugin" ]] || echo "plugin $name not found..." && . "$zplugin" || echo "failed to load  $name"
    done
}

export FPATH="$ZDOTDIR/completions/eza/completions/zsh:$FPATH"

# Enable colors and change prompt:
#autoload -U colors && colors	# Load colors
#PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
setopt autocd		# Automatically cd into typed directory.
stty stop undef		# Disable ctrl-s to freeze terminal.
setopt interactive_comments

# History in cache directory:
HISTSIZE=10000000
SAVEHIST=10000000
HISTFILE="$HOME/.local/share/zsh_history"

# Basic auto/tab complete:
autoload -U compinit bashcompinit
zstyle ':completion:*' menu select
zmodload zsh/complist
compinit
bashcompinit
_comp_options+=(globdots)		# Include hidden files.
eval "$(register-python-argcomplete pipx)"

loadplugin zsh-autosuggestions H-S-MW zsh-editing-workbench zsh-fancy-completions zui zbrowse

. "$HOME/.cargo/env"

path_append () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
        *)
        PATH="${PATH:+$PATH}:$1"
    esac
}
# include .local/bin
path_append "$HOME/.local/bin"

# include .bin
path_append "$HOME/.bin"

# include spicetify path
path_append "$HOME/.spicetify"

# include volta path
export VOLTA_HOME="$HOME/.volta"
path_append "$VOLTA_HOME/bin"

fastfetch

eval "$(navi widget zsh)"
eval "$(zoxide init zsh)"
eval "$(starship init zsh)"
loadplugin F-Sy-H

. "$HOME/.config/broot/launcher/bash/br"

Additional information

I don't use Zi

Self-service

  • I'd be willing to address this documentation request myself.

Have you read the Contributing Guidelines?

Are you familiar with the Contributor Covenant Code of Conduct?

Contact Details

[email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.