Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oh My ZSH Support #3

Open
DrgnFireYellow opened this issue Nov 29, 2022 · 1 comment
Open

Oh My ZSH Support #3

DrgnFireYellow opened this issue Nov 29, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed postponed until further notice

Comments

@DrgnFireYellow
Copy link
Owner

I believe that a good Quality of Life improvement to zlugin would be to allow the user to use oh my zsh underneath zlugin. The command used for this would be zlugin_omz.

@DrgnFireYellow DrgnFireYellow added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Nov 29, 2022
@DrgnFireYellow DrgnFireYellow self-assigned this Nov 29, 2022
@DrgnFireYellow DrgnFireYellow pinned this issue Nov 29, 2022
@mattmc3
Copy link

mattmc3 commented Mar 14, 2024

If you're willing to include some arcane black magic, you can support Oh My Zsh by using split/join syntax and then passing the repo as ohmyzsh/ohmyzsh/path/to/plugin/dir. For example:

$ # Here's how split/join would work to pull out the user/repo part:
$ plugin="ohmyzsh/ohmyzsh/plugins/extract"
$ repo="${(@j:/:)${(@s:/:)plugin}[1,2]}"
$ echo $repo
ohmyzsh/ohmyzsh

So with just a bit of that magic, and with a couple extra flourishes to support updating plugins and also fixing a bug that causes double loading plugins, your micro-plugin manager becomes:

function zlugin_reload() {
    # Initializes downloaded plugins
    local -a inits=(${ZDOTDIR:-~}/.zlugin/$1/*.{plugin.zsh,zsh-theme,zsh,sh}(N))
    (( $#inits )) && source $inits[1]
}

function zlugin() {
    # Downloads a plugin and reloads
    # Syntax: zlugin [string: github repository of a plugin]
    local repo="${(@j:/:)${(@s:/:)1}[1,2]}"
    [[ -d ${ZDOTDIR:-~}/.zlugin/$repo ]] ||
      git clone "https://github.com/$repo.git" ${ZDOTDIR:-~}/.zlugin/$repo &>> ${ZDOTDIR:-~}/zlugin.log
    zlugin_reload $1
}

function update_zlugin() {
    # Updates to the latest version of zlugin
    # NOTE: The update will not take effect until you restart your shell
    echo "Updating repos"
    local repo; for repo in ${ZDOTDIR:-~}/.zlugin/*(/); echo "Updating $repo" && git -C $repo pull
    echo "Updating zlugin"
    curl -s https://raw.githubusercontent.com/DrgnFireYellow/zlugin/main/zlugin.zsh > ${ZDOTDIR:-~}/.zlugin/zlugin.zsh
    echo "Update complete!"
}

I tested with this .zshrc, and it's pretty solid:

# sub-plugins supported
zlugin belak/zsh-utils/history
zlugin belak/zsh-utils/completion
zlugin belak/zsh-utils/utility
zlugin ohmyzsh/ohmyzsh/plugins/extract
zlugin ohmyzsh/ohmyzsh/plugins/magic-enter

# *.sh bash plugins supported
zlugin rupa/z

# zsh-themes supported
zlugin dracula/zsh
# zlugin sindresorhus/pure

# double-load bug is fixed
zlugin zsh-users/zsh-syntax-highlighting
zlugin zsh-users/zsh-autosuggestions
zlugin zsh-users/zsh-history-substring-search

I went on this journey once and it was a ton of fun. Nice project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed postponed until further notice
Projects
None yet
Development

No branches or pull requests

2 participants