10 ms·
Speeding up my ZSH shell
- suralind 1y agonushell gang since few weeks ago
- deleted 1y ago[deleted]
- mshroyer 1y agoI don't know if this is somehow particular to my setup, but on both macOS and Linux I find that simply running full `compinit` fails to update mtime on `~/.zcompdump` when nothing's changed. That causes this optimization to fail, for me, if my completions haven't changed within the last day. This is fixed by adding an explicit `touch ~/.zcompdump` in the branch that runs a full `compinit`.
- srvmshr 1y agoI discovered this issue 2-3 years ago. On slightly older machines, there was a palpable startup time. My fix was going through OhMyZSH and stripping away all the parts that I felt unnecessary (I call this my "leanZSH" and its considerably lighter version of OMZ.) It doesn't track upstream, and I manually update the plugin directory once in a while. Surprisingly OhmyZSH is pretty modular and doesn't break easily. [Not the best hackjob out there but here it is: https://github.com/gradientwolf/leanzsh https://github.com/gradientwolf/leanzsh If you want to update it just copy over the latest `plugin/` folder from OMZ repo. You can get rid of all the plugins you dont want, as well as the themes. It somehow works]
- SamDc73 1y agoI think you're better off switching to https://starship.rs https://starship.rs I did try to do my whole zsh config/theme from scratch, but it did take some time and lot of small features here and there were no worth the effort (like python version, vevn, and such) so I just switched to starship which is very fast and easy to use
- lompad 1y agoWhy not just use fish at that point? It's been rewritten in Rust too. To me personally, oh-my-zsh and similar projects feel like a worse version of the stuff fish brings by default.
- Jubijub 1y agoFish is awesome, but there are times you need POSIX/ bash-like shell syntax
- ewuhic 1y agoThen you open bash and get POSIX and not bash-like, but bash.
- krab 1y agoIn fact, sometimes I open bash even from zsh. When pasting from a script and debugging why something doesn't work as expected, I don't want bash-like. For ad-hoc loops, bash-like works well for me thanks to the familiarity of syntax.
- MillironX 1y agoYou can use Antidote to selectively load the parts of OhMyZsh you need - https://github.com/getantidote/use-omz https://github.com/getantidote/use-omz My own usage: https://code.millironx.com/millironx/nix-dotfiles/src/commit/73b7329a11dcc38070b2f36a646a81465434445e/homes/common.nix#L155-L174 https://code.millironx.com/millironx/nix-dotfiles/src/commit...
- rezmason 1y agoAha! Now I know that nvm was slowing my shell startup down. Now I've reconfigured .zshrc to lazy-load nvm, and everything's snappy: zstyle ':omz:plugins:nvm' lazy yes
- saikatsg 1y agoCool! Also, there's a zsh wrapper for nvm: https://github.com/lukechilds/zsh-nvm?tab=readme-ov-file#lazy-loading https://github.com/lukechilds/zsh-nvm?tab=readme-ov-file#laz...
- satvikpendem 1y agoJust use fnm, I like it much better
- dcre 1y agoSame. I switched to fnm.
- Zizizizz 1y agoYou should try switching to mise. I tried fnm too which was an improvement but mise does the same as fast and supports essentially every language
- nobleach 1y agoDefinitely Mise! I was an asdf user for a couple of years and Mise was such a nice replacement. I have to juggle several other languages, and each having its own tool for tool version management was a non-starter.
- mcc1ane 1y agohttps://github.com/romkatv/powerlevel10k?tab=readme-ov-file#instant-prompt https://github.com/romkatv/powerlevel10k?tab=readme-ov-file#...
- satvikpendem 1y agoSadly it's essentially discontinued
- trallnag 1y agoI'll continue using it until the core features like instant prompt and transient prompt start to break or I run into bugs that I can't live with
- nadir_ishiguro 1y agoNo. The author simply sees it as basically complete and decided to spend the time he has fixing bugs instead of taking care of issues.
- satvikpendem 1y ago> MOST BUGS WILL GO UNFIXED
- opk 1y agoIt's just a shell prompt. There really won't be much in the way of bugs. And it's popular. Doing a quick scan of github issues, there's no shortage of questions where some other random plugin or weird terminal emulator has strange interactions. I think the author can be forgiven for not wanting to diagnose such combinations.
- dolmen 1y agoAs a former maintainer of LiquidPrompt I can only agree.
- 1y ago
- WhyNotHugo 1y agoOh-my-zsh has a lot of cool and handy features, but it is a huge and complex beast. Personally, I only cared about 3–4 features, so I simply removed it and sought out how to enable those features alone. Additionally, a lot of functionality which I wanted wasn’t there in OMZ, so my setup had a lot of custom bits anyway. My zshrc, for reference: https://git.sr.ht/~whynothugo/dotfiles/tree/269248912920d25e904198d628d05692593de4a6/item/home/.zshrc https://git.sr.ht/~whynothugo/dotfiles/tree/269248912920d25e...
- bravesoul2 1y agoWhat's with the emoji alias?
- WhyNotHugo 1y agoLol. Slipped in by accident, should never have been committed. Part of some messing around / test.
- bravesoul2 1y agoFunny! I was hoping it was a crazy hack :)
- mroche 1y agoI am absolutely stealing this: export LESS='-RX --quit-if-one-screen'
- JimDabell 1y agoThis is my config: https://pastebin.com/ATZeFJRk https://pastebin.com/ATZeFJRk I find that for persistent configuration like this, it helps to use the long option format and include the man page contents for those options. I don’t have these options memorised so it’s good to have a reference handy to remind me.
- yurishimo 1y agoWhat does this do exactly?
- RGBCube 1y agoFrom the post, it seems like ZSH tries to update on every shell spawn: DISABLE_AUTO_UPDATE="true" WTF? Even if we ignore the crime of non-critical software updating itself, the fact that it does it on every start instead of every day or week is insane. I do not want my shell sending network requests to odd servers without explicit action from me, thanks.
- c-hendricks 1y agooh-my-zsh, not zsh
- slacktivism123 1y ago>it seems like ZSH tries to update on every shell spawn Learn your tools first, not bloated frameworks. There's a gulf of difference between vanilla zsh and this: >Community-driven (with 2,400+ contributors) framework for managing your zsh configuration >Includes 300+ optional plugins (rails, git, macOS, hub, docker, homebrew, node, php, python, etc) >140+ themes to spice up your morning, and an auto-update tool that makes it easy to keep up with the latest updates from the community
- RGBCube 1y agoSorry, I meant oh-my-zsh. I know that the core shell doesn't update. I still think it's bad. You shouldn't rely on a million different package managers, just 1 is enough. (2 if you are feeling spicy: Flatpak)
- Arrowmaster 1y agoThat's what ZSH has turned into. Every new user installs OMZ because that's what the Internet tells them to do. Then their shell config turns into a huge mess. So half the users are using OMZ with a bloated slow config and the other half are reinventing new config managers every year because of how terrible OMZ has become. And constantly churning through them as they keep getting abandoned. I've been happily using zsh4humans for years but will need to find a replacement at some point as it's now going unmaintained too.
- jasonjmcghee 1y agoThanks - that pushed me to profile, and as others mentioned nvm was the biggest culprit, then powerline status, which i swapped to powerline-go. nice and snappy startup time now.
- forsalebypwner 1y agosame here, nvm was absolutely wrecking my startup time and I almost never use npm/nodejs.
- stouset 1y agoFish shell with starship. You will never look back.
- marliechiller 1y agoFunnily enough, the startup delay of oh-my-zsh is exactly what prompted me to try out fish and eventually starship on top. I have not looked back as you say!
- deleted 1y ago[deleted]
- raekk 1y ago[dead]
- rtkaratekid 1y agoI started using fish on a dare from a coworker who thought it would be funny. Joke’s on them, it’s been five years and I still love it. Started using starship this year and agree with you.
- leosanchez 1y agoMy fish config is maybe 5-10 lines just starship, zoxide, direnv.
- f311a 1y agoFish is nice, but syntax difference is a no-go for me. I frequently log into different servers that usually use bash. I miss simple things like alias when I temporary want to assign long commands to a shorter alias.
- stouset 1y agoI still script in bash and I still know bash. It’s just not that big an ordeal to code-switch between the two.
- opk 1y agoI'd be rather skeptical about the "fix" of updating the completion cache once a day only. Enabling oh-my-zsh already runs `compinit` and it does so after changing the function path in `fpath`. By running it again with a different `fpath` you invalidate the previous cache - meaning it builds a fresh cache twice every time you start zsh. If you use a plugin framework that already runs compinit, simply don't run it again separately. And make sure that `compinit` is only run after the final plugin or whatever has finished changing `fpath`. If you get that right, you'll only ever need to regenerate the cache when something actually updates.
- ivanjermakov 1y agoOh-my-zsh is very bloated. You might not need it, since its most used features can be implemented with zsh directly: https://ianyepan.github.io/posts/moving-away-from-ohmyzsh/ https://ianyepan.github.io/posts/moving-away-from-ohmyzsh/
- jeffbee 1y agoOMZ should be classified under "supply chain attack as a service". I can't believe anyone uses it.
- raffraffraff 1y agoAs a long time Linux + bash user I switched to zsh three months ago when I was forced to use a Mac at a new job. In every previous job I was able to insist on Linux, but this one is very corporate. I decided not to fight it, except to install AltTab, Karabiner, Rectangle and a script that detects which screen my mouse is on so I can alt-tab through ALL the stuff on that screen (sane XFCE / KDE behaviour). I can't get used to the atrocious keyboard shortcuts but I have gotten used to the "non-UK UK keyboard layout". And zsh. I honestly don't know why I didn't just brew install bash right from the start. Without even realising I was doing it, I fought with this bloated bastard for 2 months before finally asking what the fuck I was doing. I sped up my shell by switching back to bash.
- soraminazuki 1y agoWhat on earth are you talking about? zsh isn't bloated by any stretch, nor is it any slower than bash in any meaningful way. Chances are, like in the article, you installed oh-my-zsh, a third party configuration framework.
- deleted 1y ago[deleted]
- cb321 1y agoSome data in support of @soraminazuki (who makes good points throughout this thread) on an i7-1370P linux laptop running Linux 6.15.7: $ tim 'bash -lic logout' 'zsh -lic logout' 55.3 +- 3.7 μs (AlreadySubtracted)Overhead 7454 +- 26 μs bash -lic logout 7934 +- 39 μs zsh -lic logout (Using https://github.com/c-blake/bu/blob/main/doc/tim.md https://github.com/c-blake/bu/blob/main/doc/tim.md) About 20,000 entries in the Zsh history slowing it a little. All completion activated (but zcompile'd, along with a very large digraphs.zwc). I think most would not be troubled by taking 1.06X longer, though, especially at this 8 ms scale and for interactive session initiation. Note this test upper bounds Time To First Prompt { a different "TTFP" from Time To First Plot ;-) }, since it also exits as part of the `-c`.
- homebrewer 1y ago
- udayjdv 1y ago[dead]
- Sparkenstein 1y agoI moved to fish 3 years ago, haven't noticed a difference till date.
- gjvc 1y agomake sure you haven't got too many plugins enabled (start with zero and work up / enable them as needed)
- soraminazuki 1y agoWith articles like these popping up all the time, oh-my-zsh is seriously harming zsh's reputation. It's giving the wrong impression of zsh being slow and bloated. zsh doesn't need configuration frameworks or plugins. All it needs is a change in the default settings so that its powerful completion works out the box. It currently needs more than ideal amount of tweaks to the defaults, which is probably why people flock to these frameworks.
- hdjrudni 1y agoI don't want to spend ages figuring out which knobs to turn to get a half decent shell. If there's an alternative to oh-my-zsh that looks halfway decent, has that nice fzf integrated, and the 'ghost text' history suggestions, then I welcome it!
- alabhyajindal 1y agoYou should try fish shell. Great user experience out of the box, including history suggestions. https://fishshell.com https://fishshell.com
- cbarrick 1y agoThe incompatible syntax of fish makes it a no go for me. As an SRE, at my day job I often need to copy/paste commands that are generated from a playbook. Our playbooks use Bash, and in practice Zsh is compatible. But a co-worker using fish often has to manually modify commands before running, and I'm not about that life. The problem with fish is mostly the different syntax for setting variables and lack of heredocs. Sometimes the string substitution differences come up too.
- fgonzag 1y agoSRE running copy pasted commands directly instead of a script or some automation solution? I don't think the problem is the shell...
- f311a 1y agoDid something similar recently as well. I did not notice any need for plugins from day one of switching. Fzf can replace a lot of plugins if you know how to use it. Things like git branch name and virtual envs are handled by starship. My custom config is less than 10 lines now: export HISTSIZE=1000000000 export SAVEHIST=$HISTSIZE setopt EXTENDED_HISTORY setopt autocd autoload -U compinit; compinit source <(fzf --zsh) eval "$(starship init zsh)" set -o vi
- samgranieri 1y agoOoh, bookmarked! My 11 year old zsh setup, which started from YADR and has stuff from other places preserved in chezmoi is starting to drag. Time to speed this up or just rip up and redo
- bananapub 1y agofwiw you can just use zsh4humans (as long as you promise not to bother the author) and have all the things in omz that matter and approximately zero startup time
- jpmonette 1y agoFish is the way to go! Used to be a fan of ZSH but also struggled with performance issues. No performance issue with Fish! Only issue might be plugins / some copy/paste bash stuff, but it's so worth the performance.
- massysett 1y agoThe instant I saw the title I knew the post would be “I turned off oh-my-zsh” or “I tweaked oh-my-zsh.” Yes zsh has a bunch of settings and dense documentation, and it can be hard to understand. The problem with something like oh-my-zsh is that now you have two things you don’t understand, and worse, when something doesn’t work you don’t know which one isn’t working or where to look.
- Jerry2 1y agoI switched to Prezto [0] because I found OMZ too slow. Prezto is much faster out of the box and doesn’t have a lot of things enabled by default. Definitely give it a try if you find OMZ too slow on your machine. [0] https://github.com/sorin-ionescu/prezto https://github.com/sorin-ionescu/prezto
- jauntywundrkind 1y agoThere's so many plugin systems for zsh. From comments it seems like Pretzo is the main one suggested. But there's a huge list of different offerings. Looking at https://github.com/sindresorhus/pure?tab=readme-ov-file#integration https://github.com/sindresorhus/pure?tab=readme-ov-file#inte... , there's also for example zim, zplug, zinit, zi. It's be so great to have see some deeper investigations or comparisons: is Pretzo really the best choice? Aside from seeming popularity, why? At least found this neat gist with a cheat sheet for different zsh plugin systems (and how very many there are!) https://gist.github.com/olets/06009589d7887617e061481e22cf5a4a https://gist.github.com/olets/06009589d7887617e061481e22cf5a...
- OptionOfT 1y agoI use Starship, so this applies to both ZSH & Fish: If you have the Python environment displayed in Starship, your largest gain in speed is to replace pyenv and pyenv-virtualenv by uv.
- gregwebs 1y agoI switched from Oh My Zsh to ZimFW because they have benchmarks showing it is faster: https://github.com/zimfw/zimfw https://github.com/zimfw/zimfw
- st3fan 1y agoeasier to switch to fish
- eviks 1y ago> Making Spaceship Prompt Faster (22.47% → ~5%) Or even better switch to starship, a compiled binary doing the prompt formatting?
- wodenokoto 1y agoWhat's the benefit of using oh-my-zsh and starship at the same time?
- matttproud 1y agoI don't have anything against ZSH or similar shells. I think they are great, but they are not my thing. Latency is a deal-breaker for me, and this is where autocompletion engines generally introduce surprising user-interactive pauses. I've generally settled with using mksh (or OpenBSD's KSH depending on the environment) with little configuration outside of aliases, variables, and few local functions. I'm not left with this inkling feeling like accidentally running find(1) over an AutoFS file system backed by NFS that needs to authenticate, mount, and then run the operation. When I need something more sophisticated, I lean on using Go or Elvish and potentially delegate some UI elements out to https://github.com/charmbracelet/gum https://github.com/charmbracelet/gum. I'd rather keep my shell simpler and delegate out any other complexity to these other programs. Autocompletion and these other features simply aren’t free.
- cyberpunk 1y agooksh and set -o vi have made it virtually impossible for me to type commands into other people computers. I get bewildered looks when i hit v and edit my commands in vim from the youth but whatever, they’ll learn someday :))
- nobleach 1y agoI was an OMZ user pretty much since I adopted ZSH many years ago. I never really experienced much of the slowdown(s) that people tend to complain about. Even still, getting my dotfiles set up on a new machine was always a little bit of pain. I'd try to install OMZ from my OS' package manager, remember that that rarely worked perfectly, gone back to OMZ's webpage and copied the cURL command... the fought with FZF shell integration for about an hour. Finally one Saturday I just stripped it all out. I went with raw ZSH and Antigen for the few plugins I care about. Spinning up new machine is now painless. And I always like simplifying things.
- wyclif 1y agoThing is, a lot of how OMZ affects your zsh usage is based on usage patterns. For instance, I usually have zsh running in a terminal that is always open and running. Now, if I close my terminal and restart, then I notice that OMZ is kinda slow and it irritates me, even if it's only for a second. But that almost never happens. Anyway, I'm going to be revisiting my zsh config soon and I'll be looking for ways to make sure I'm only using plugins that I absolutely do need. My principle in the past with workflows in zsh and Neovim is that I only add crucial plugins and try to keep my config minimal. Maybe I've gotten away from that a bit and need to regroup, so I find threads like this one useful to keep up with what's current.
- lenerdenator 1y agoI do find myself running into problems with NVM slowing things down in zsh; anyone else experiencing this?
- Ajnasz 1y agoI created an alternative because of nvm's slowness: https://github.com/Ajnasz/znvm https://github.com/Ajnasz/znvm
- Pwntastic 1y agoI got tired of nvm being incredibly slow and recently switched to fnm, which has been much faster and has drop-in compatibility with the .nvmrc files that nvm used
- leimbacher 1y agoSarcasm: just switch to bash and know what's running on every prompt. Sure, if you need to get git status on a slow disk then anything will be slow. I have not read the article, BTW.