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

Simplify Zsh config and remove bloat #1881

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fesowowako
Copy link

Pull Request

Description

In my feature request, I initially misstated that Powerlevel10k was unmaintained. However, recent activity shows it is still receiving updates.

  • Revised Zsh Configuration: Improved clarity and ease of user configuration, maintaining the same functionality.
  • Removed Dependencies: Eliminated the need for additional packages like Powerlevel10k and Oh My Zsh, simplifying the setup.
  • Plugin Management: Utilised Zinit as the plugin manager and added three previously used plugins.
  • Omitted Oh My Zsh: Chose not to include Oh My Zsh due to its bloat and noticeable impact on shell startup time.
  • Implemented Zinit Snippets: Added plugins using Zinit’s snippet functionality for installation via URL.

Additional Notes:

  • The maintainer of these dotfiles may need to review restore_shl.sh, as I’m uncertain about what to remove to prevent potential issues.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (non-breaking change; modified files are limited to the documentations)
  • Technical debt (a code change that does not fix a bug or add a feature but makes something clearer for devs)
  • Other (provide details below)

Checklist

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My commit message follows the commit guidelines.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added a changelog entry.
  • I have added necessary comments/documentation to my code.
  • I have added tests to cover my changes.
  • I have tested my code locally and it works as expected.
  • All new and existing tests passed.

In my [feature request](prasanthrangan#1880), I initially misstated that Powerlevel10k was unmaintained. However, recent activity shows it is still receiving updates.

- Revised Zsh Configuration: Improved clarity and ease of user configuration, maintaining the same functionality.
- Removed Dependencies: Eliminated the need for additional packages like Powerlevel10k and Oh My Zsh, simplifying the setup.
- Plugin Management: Utilised Zinit as the plugin manager and added three previously used plugins.
- Omitted Oh My Zsh: Chose not to include Oh My Zsh due to its bloat and noticeable impact on shell startup time.
- Implemented Zinit Snippets: Added plugins using Zinit’s snippet functionality for installation via URL.

Additional Notes:
- The maintainer of these dotfiles may need to review restore_shl.sh, as I’m uncertain about what to remove to prevent potential issues.
@rubiin
Copy link
Contributor

rubiin commented Sep 24, 2024

I do agree on the bloat of ohmyzsh. This will be a breaking change
also I recently came across this benchmark and zinit seems to be slower than the competitions https://github.com/rossmacarthur/zsh-plugin-manager-benchmark

maybe you can benchmark and show results between them

Configs/.zshrc Outdated Show resolved Hide resolved
@zeerayne
Copy link
Contributor

Also, as an conversation: maybe to change p10k to i.e. oh-my-posh? Because p10k won't be receiving updates anymore.

@rubiin
Copy link
Contributor

rubiin commented Sep 25, 2024

Also, as an conversation: maybe to change p10k to i.e. oh-my-posh? Because p10k won't be receiving updates anymore.

It will be receiving updates but the pace of updates will be very slow cc: romkatv/powerlevel10k#2690 (comment) . Its a matter of time , before a fork appears

@fesowowako
Copy link
Author

I do agree on the bloat of ohmyzsh. This will be a breaking change also I recently came across this benchmark and zinit seems to be slower than the competitions https://github.com/rossmacarthur/zsh-plugin-manager-benchmark

maybe you can benchmark and show results between them

install
load

Apologies for the delayed response; I’ve been rather busy lately. Anyway, here are the benchmarks: zinit is slightly slower than some of the alternatives, but I’ve chosen to stick with zinit because it’s the most actively maintained option. It’s consistently being improved, and the load time isn’t a significant issue. That’s just my take on it. However, if you prefer to go with a different plugin manager, I’ll accommodate that.

@rubiin
Copy link
Contributor

rubiin commented Sep 26, 2024

Yeah . Lets hold on with the PR and look for a viable option that doesnt compromise perf with ux like ohmyzsh

@zeerayne
Copy link
Contributor

I'm using sheldon for plugins and oh-my-posh for theming. Can't complain about any performance issues on old i7 8700. Profile loads rapidly.

$ time zsh -i -c exit
zsh -i -c exit  0.04s user 0.03s system 91% cpu 0.081 total

@rubiin
Copy link
Contributor

rubiin commented Sep 26, 2024

@zeerayne true. sheldon seems nice. I am also looking at zim. Deciding between zim and shelldon. Zsh4humans is the fastest of them all . But it wont be getting any bug fixes and patches

@zeerayne can you share your configs

@zeerayne
Copy link
Contributor

@rubiin Here you go

~/.config/sheldon/plugins.toml

shell = "zsh"

plugins.'zsh-users/zsh-completions'.github = 'zsh-users/zsh-completions'
plugins.'zsh-users/zsh-syntax-highlighting'.github = 'zsh-users/zsh-syntax-highlighting'
plugins.'zsh-users/zsh-history-substring-search'.github = 'zsh-users/zsh-history-substring-search'
plugins.'Aloxaf/fzf-tab'.github = 'Aloxaf/fzf-tab'

~/.config/oh-my-posh/config.toml

"$schema" = "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json"
version = 2
disable_notice = true

[[blocks]]
  type = 'prompt'
  alignment = 'left'
  newline = true

  [[blocks.segments]]
    type = 'path'
    style = 'plain'
    template = '{{ .Path }} '
    foreground = 'lightGreen'

    [blocks.segments.properties]
      style = 'full'

  [[blocks.segments]]
    type = 'git'
    style = 'plain'
    template = '<#ffffff>on</> {{ .HEAD }}{{ if gt .StashCount 0 }}  {{ .StashCount }}{{ end }} '

    [blocks.segments.properties]
      branch_icon = ''
      fetch_stash_count = true

  [[blocks.segments]]
    type = 'python'
    style = 'powerline'
    template = '[ {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }}] '
    foreground = '#906cff'

  [[blocks.segments]]
    type = 'go'
    style = 'powerline'
    template = '[ {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}] '
    foreground = '#7FD5EA'

  [[blocks.segments]]
    type = 'node'
    style = 'powerline'
    template = '[ {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }}] '
    foreground = '#76b367'

  [[blocks.segments]]
    type = 'ruby'
    style = 'powerline'
    template = '[ {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}] '
    foreground = '#f44336'

  [[blocks.segments]]
    type = 'java'
    style = 'powerline'
    template = '[ {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}] '
    foreground = '#ea2d2e'

  [[blocks.segments]]
    type = 'julia'
    style = 'powerline'
    template = '[ {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}] '
    foreground = '#4063D8'

[[blocks]]
  type = 'rprompt'
  overflow = 'hidden'

  [[blocks.segments]]
    type = 'executiontime'
    style = 'plain'
    template = '{{ .FormattedMs }}'
    background = 'transparent'
    foreground = 'yellow'

    [blocks.segments.properties]
      threshold = 5000.0

[[blocks]]
  type = 'prompt'
  alignment = 'left'
  newline = true

  [[blocks.segments]]
    type = 'text'
    style = 'plain'
    foreground_templates = ['{{if gt .Code 0}}red{{end}}', '{{if eq .Code 0}}magenta{{end}}']
    template = ''
    background = 'transparent'

[transient_prompt]
  foreground_templates = ['{{if gt .Code 0}}red{{end}}', '{{if eq .Code 0}}magenta{{end}}']
  template = ''
  background = 'transparent'

[secondary_prompt]
  template = '❯❯ '
  background = 'transparent'
  foreground = 'magenta'

~/.zshrc

#!/usr/bin/env zsh

# Environment variables
export EDITOR=vim

# If one of the VISUAL or EDITOR environment variables contain the string 'vi' when the shell starts up then it will be viins, 
# otherwise it will be emacs. bindkey's -e and -v options provide a convenient way to override this default choice.
bindkey -e

eval "$(dircolors -b)"
eval "$(oh-my-posh init zsh --config ~/.config/oh-my-posh/config.toml)"

# Load zsh plugins via sheldon
eval "$(sheldon source)"

# Check for zsh plugins updates weekly
SHELDON_CONFIG="${XDG_CONFIG_HOME:-${HOME}/.config}/sheldon"
if { [ ! -f "${SHELDON_CONFIG}/update.check" ] || [[ $(find "${SHELDON_CONFIG}/update.check" -mmin +10080) ]]; }; then
   sheldon lock --update
   touch "${SHELDON_CONFIG}/update.check"
fi

# History
HISTSIZE=10000
SAVEHIST=$HISTSIZE
HISTFILE=~/.zsh_history
HISTDUP=erase
setopt appendhistory
setopt sharehistory
setopt hist_ignore_space
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_ignore_dups
setopt hist_find_no_dups

zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu no

zstyle ':completion:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'

# Load completions
autoload -Uz compinit && compinit

# Autocompletion using arrow keys (based on history)
## Arrow up
bindkey "${terminfo[kcuu1]}"  history-substring-search-up
bindkey "^[[A"                history-substring-search-up
## Arrow down
bindkey "${terminfo[kcud1]}"  history-substring-search-down
bindkey "^[[B"                history-substring-search-down

# Basic keybindings
## Home
bindkey  "${terminfo[khome]}" beginning-of-line
bindkey "^[[H"                beginning-of-line
## End
bindkey  "${terminfo[kend]}"  end-of-line
bindkey "^[[F"                end-of-line
## Del
bindkey  "${terminfo[kdch1]}" delete-char
bindkey "^[[3~"               delete-char

# Helpful aliases
alias  c='clear' # clear terminal
alias  l='eza -lh  --icons=auto' # long list
alias ls='eza -1   --icons=auto' # short list
alias ll='eza -lha --icons=auto --sort=name --group-directories-first' # long list all
alias ld='eza -lhD --icons=auto' # long list dirs

# Handy change dir shortcuts
alias ..='cd ..'
alias ...='cd ../..'
alias .3='cd ../../..'
alias .4='cd ../../../..'
alias .5='cd ../../../../..'

# Always mkdir a path (this doesn't inhibit functionality to make a single dir)
alias mkdir='mkdir -p'

@rubiin
Copy link
Contributor

rubiin commented Sep 26, 2024

This is currently my ohmyzsh optimized

zsh -i -c exit  0.11s user 0.06s system 112% cpu 0.150 total

with sheldon

zsh -i -c exit  0.08s user 0.05s system 108% cpu 0.115 total

with zim

zsh -i -c exit  0.05s user 0.08s system 120% cpu 0.114 total

at the end , zim and sheldon seems to be kinda similar interms of speed

I do like sheldons way of things as it doesnt seem to clutter zshrc

@fesowowako
Copy link
Author

@rubiin sheldon appears to be quite decent and impressively quick, in my view. I haven't verified whether it's still being maintained, though. Apologies for my oversight. I suppose I could switch from zinit to Sheldon and replace powerlevel10k with ohmyposh, given that it’s consistently receiving updates. This way, we won’t have to rely on someone to fork and maintain powerlevel10k. However, I'll await your response on this before making any commitments.

@rubiin
Copy link
Contributor

rubiin commented Sep 26, 2024

@fesowowako I suppose we can do that. Since powerlevel10k is on life support
When working with ohmyposh , be sure to match the current prompt appearance as close as possible
Same with sheldon as well like you did with zinit.
That way we wont break anything

@fesowowako
Copy link
Author

@rubiin would you like me to add either oh-my-posh or oh-my-posh-bin to the custom_hypr.lst? I’m having a bit of trouble getting oh-my-posh to match the current powerlevel10k aesthetic. If I can’t achieve the same look, would it be acceptable to use Zeerayne's oh-my-posh configuration? It’s rather minimalistic and clean. Honestly, someone else might be better suited to make the proper adjustments than I am. However, if that's not your preference, I can simply stick with powerlevel10k for the time being, and perhaps someone else can take a crack at aligning oh-my-posh with the powerlevel10k appearance when they have the opportunity.

@rubiin
Copy link
Contributor

rubiin commented Sep 27, 2024

lets track for powerlevel10k on another PR. I am also playing with ohmyposh myself.

@rubiin
Copy link
Contributor

rubiin commented Sep 27, 2024

@kronikpillow
Copy link

kronikpillow commented Oct 4, 2024

I would have to disagree that zinit is the most "maintained and actively developed" ... as a matter of fact, there is so much contraversy going around zinit that it's insane, like ... the fact that the original maintainer deleted the entire zinit organization, then after lashback from community, and re-established forks, he reuploaded it as a new project, now you have multiple zinit repositories, with no clear line or sight, on which one is the official one, but either way, the newer one (one your not using) that is actually maintained by original dev, is not the one you presented in here ... althou im surprised by the benchmark results, zinit was once one of the fastest ...

zimfw is very nice, but lacks vi keybinding compatibility, most plugins and enrivonment settings are tailored towards Emacs like users of shells ^^ requires tinkering if you want vi keybindings ... also, when using zimfw you need to make sure that no plugins run compinit, as it's own completion module does it at the end

@kronikpillow
Copy link

kronikpillow commented Oct 4, 2024

I have a custom basic .zshrc no frameworks, with a bunch of plugins, and it loads much faster then any framework, while keeps most common used settings taken from zimfw, zap-zsh, and various other .zshrc's i found on the net

zsh -i -c exit 0.03s user 0.01s system 99% cpu 0.043 total

want me to share it?

@rubiin
Copy link
Contributor

rubiin commented Oct 15, 2024

@kronikpillow if you have a dotfiles repo, do share. Or maybe your zshrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants