If you want to change the colors of current directory, see this.
If you mean the small blue triangle on the left, that's not displayed by Powerlevel10k. It's iTerm2 Shell Integration Indicator. Many users turn them off. You can do that via iTerm2 -> Profile -> Terminal -> Show mark indicators.
I understand the logic you're trying to make with your -a
/-b
flags, but suppose I want to give one of those flags an element beginning with a -
? I much prefer -a
or -b
to take exactly one argument, which would then consume the following argument, whether it looks like a flag or not.
Also, _input=(`echo $@`)
prevents a user from specifying an --option 'with spaces'
. You can iterate over the command line arguments with just
for arg; do ... done
Anyway, check out zparseopts
, in the zsh/util
module. Here's a demo I just wrote.
See man zshmodules
for more information.
I found that article on Google too and was like WTF? They’re talking about https://github.com/rupa/z as if it’s built into ZSH (and Bash) - maybe because it’s named “z”? The author is not very knowledgeable. I’d recommend this instead: https://www.slideshare.net/mobile/jaguardesignstudio/why-zsh-is-cooler-than-your-shell-16194692
From the post:
> Antigen cites that it is directly inspired by Vundle, which is a great plugin manager for Vim. Vundle was inspired by Pathogen which was the first plugin manager for Vim. Thus this is the reason Antigen is named after an Immunology term.
Your previous comment was spot on -- Antigen's name is a tribute to Pathogen.
It's interesting to see that people were looking for a "vaccine" against the "disease" of oh-my-zsh since at least 2014 (that's 7 years ago!). The specific criticism doesn't seem to apply nowadays though. Good job on the part of oh-my-zsh I guess. Perhaps Marc Cornellà becoming the main maintainer was a turning point?
Another historical artifact from even older times is this PR that resulted in prezto forking off oh-my-zsh. Fascinating read. 10 years later oh-my-zsh is enjoying unprecedented popularity while prezto seems like one of many despite much higher technical skill of its author. Reading the PR today this seems inevitable but I doubt I could have made this prediction back then.
I just checked again and no, there doesn’t seem to be any good way to disable OMZ’s completion module. On the other hand, OMZ‘s completion module doesn’t actually seem to do all that much. So, don’t worry about it. I should probably remove OMZ from that sentence. :)
> Would it be enough to source this plugin before OMZ runs compinit?
It doesn’t really matter. Whichever way you source zsh-autocomplete
, it will care by itself that it gets initialized correctly. :) But in case you want to minimize your shell’s startup time: It’s generally fastest to source zsh-autocomplete
as early as possible.
I don't use oh-my-zsh
, but here is the link to their implementation: https://github.com/ohmyzsh/ohmyzsh/pull/7578/files. Generally you need to add the directory where the completion file exists to fpath
before the completion is initialized with compinit
. You shouldn't source the file anyway. In their case you need to find out where $ZSH_CUSTOM
is in your system
Okay, I looked: https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/pj/pj.plugin.zsh
It calls compadd and compdef once, but that’s not much to go on to really understand completions, sorry. Thanks anyway.
a very interesting hack I discovered today, credits go to Daniel Shahaf: http://www.zsh.org/mla/users//2017/msg00422.html
basically you can split up your zsh completions by category, as demonstrated in the screenshot. there, I just typed d_[tab]
I used asciinema to make little films of myself using the terminal, and then I used asciicast2gif to turn those films into gifs.
I've optimized the compact already optimized zsh-syntax-highlighting part – by 40% in total – HSMW is now really fast – here are as much as 20 complex history entries per page: https://asciinema.org/a/89406
alias gmail="curl -u username:password --silent 'https://mail.google.com/mail/feed/atom' | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print \$i}}' | perl -pe 's/^<title>(.*)<\/title>.*<name>(.*)<\/name>.*$/\$2 - \$1/'"
The parameters ($1
, $2
) needed to be escaped to be passed to perl, otherwise the shell replaces them beforehand.
I prefer fzf, a tool you must install when you use the command line. It comes with a built in keybind that maps CTRL-r to fuzzy search your history (and a lot more features).
Yeah it looks like I have a lot of junk in this file. I don't really know where to begin in taking stuff out :/
It's posted here!
Edit: The error is showing now to be at line 61, but pasting it into an editor, it's 60 lines long.
I set list-promt
and select-promt
to disable the annoying do you wish to...
message, but At Top:Hit TAB...
is still enabled. I don't what either
Maybe this recording helps: https://asciinema.org/a/BluGyxHift2Wxkd9YTePMf1BV . The autocomplete plugin is called zsh-autocomplete.
Im looking for is a more IDE/search bar behaviour: You type and some suggestions appear underneath. You can choose them or simply just keep typing. That's why i want to disable the At Top
message. I do not care what all the options are, i just need the top ones
NordVPN has its own dedicated prompt segment in powerlevel10k, which shows which country you are connected to. You need to install nordvpn
CLI tool for it to work. E.g., see here for Linux.
Add the command-not-found plugin for oh-my-zsh.
> This plugin uses the command-not-found package for zsh to provide suggested packages to be installed if a command cannot be found.
To use it, add command-not-found to the plugins array of your zshrc file:
plugins=(... command-not-found)
Znap is actually my favorite among them! I recently wrote myself a little script thats just a very very basic plugin manager and recommend znap for those looking for a more full-featured alternative. Thanks for your great work!
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
i have to add something like this, also i press ctrl+t
to get the completion of fzf
, and tab
for normal completion.
also https://github.com/junegunn/fzf if it don't work try to install from here
Looks useful, but I think I prefer the history widget shipped with fzf, because fzf in itself is more versatile and the shell widget seems like less overhead than a C binary to me. Nevertheless, good find! The additional features beyond fzf (e.g. favorites) might be useful.
For that sort of functionality, I would use fzf.
Then you could do git commit ShortenLinkForm**<tab>
and get interactive completion of all files below current folder fuzzily matching ShortenLinkForm
.
I did it a slightly different way. I wanted to CD into whatever directory I fuzzy selected. So instead I used fzf:
ctrlp() {
dir="$(find -type d | grep -v .git | grep -v node_modules | fzf)";
[[ -d "$dir" ]] && cd $dir;
zle reset-prompt
}
zle -N ctrlp bindkey "^p" ctrlp
Also, after installing fzf my CTRL+R is now a fuzzy select! :)
I have the same issue, but it has not started with Montery but with a very recent omz update
.
I could track down the change to the following commit in omz:
7f49494 - fix(dirhistory): fix ALT+Up/Down key bindings for Terminal.app
After reverting that commit, up/down work as before. I do not understand what that commit meant to "fix" in the first place.
Fair enough. You've contributed an open source implementation of genpass
and I appreciate it. You don't have an obligation to improve or support it.
I've sent a PR to ohmyzsh: https://github.com/ohmyzsh/ohmyzsh/pull/9520.
The most used zsh config is by far oh-my-zsh to the point where a lot of people use zsh/oh-my-zsh as synonyms
that being said it is my opinion way to many different configs/themes/plugin in one single place and easily slows down your shell but good to look at and find inspirations at their wiki page
It’s this line in Oh My Zsh that’s doing this. It’s a common complaint among users. It only slows things down if bracketed paste is supported by the terminal.
The variable you want is LS_COLORS. Oh-my-zsh has tons of good examples in its themes. Here’s the OMZ default color setting: https://github.com/ohmyzsh/ohmyzsh/blob/d0d01c0bbf32ffe1dc22a66620ca85669c77e6b8/lib/theme-and-appearance.zsh#L5
UPDATE:
This has been around for awhile apparently, and there's a fix. It's a tab completion issue specifically around underscores, and the fix is simply to add the following to .zshrc:
zstyle ':completion:*' matcher-list 'r:[[:ascii:]]||[[:ascii:]]=** r:|=* m:{a-z\-}={A-Z\_}'
That error comes from https://github.com/ohmyzsh/ohmyzsh/blob/5c1a5c6ce924755095020fd829b08f0ee205a723/tools/check_for_upgrade.sh#L23, which references ${ZSH_CACHE_DIR}
, which should be ${ZSH}/cache
, unless you have it set otherwise?
The time is time since last commit (which I don't understand why that's useful, but okay).
Not sure about the red ø-like symbol.
I cloned the oh-my-zsh Github repository and executed grep
in there. Are there any other repositories than the one I mentioned that are cloned when executing the command that installs oh-my-zsh
?
UPDATE: Ok did a search on github and turns out this is an old issue (2014):
https://github.com/ohmyzsh/ohmyzsh/pull/3359
Apparently it was corrected (as I suggested above), but then that broke things, since zsh actually has a default value for HISTSIZE of 30, so this change makes everyone have a HISTSIZE of 30.
So the advice now is if you want to override any oh-my-zsh default values such as these, to do so at the end of your .zshrc file.
Thanks, that's some old, old code that I copied from Oh-My-Zsh when I transitioned away from it.
I hope this isn't too off topic, but regarding, "if you use so many plugins, or you're a developer and you need to use the virtual environment mangers ... You have no choice, zplugin is the only solution", I'd like to point out that nix is a great option. It was built for the purpose of managing endless different environment configurations far beyond just shell plugins/settings.
Nope, there is no way. It is standard terminal emulator behavior to send ^I
for tab
and ^M
for return
. Likewise, there are no codes for ctrl-;
or ctrl-.
.
Why? Because all this stuff was originally built in the 70s and everything is transmitted in ASCII characters. Have a look at this chart to see what's possible with ASCII.
Yes, there is a proposal for more comprehensive keyboard handling in terminals, but so far, only a couple of terminals implement it (often incompletely) and zsh
does not support it.
The wait0
case is scheduled as follows:
ANFD="13371337" # for older Zsh + noclobber option exec {ANFD}< <(builtin print run;) command true # workaround a Zsh bug, see: http://www.zsh.org/mla/workers/2018/msg00966.html zle -F "$ANFD" -zplg-scheduler
So adding a sleep
before the print
would help, however I'm hesitating with such a change, as it will make the first plugin load later.
Oh, I doubt it's a problem on zsh's end. As I said, the Arch Linux packages have the man pages, and http://www.zsh.org/pub/zsh-${pkgver}.tar.bz2
has the man pages in it. Looking over the PKGBUILD
, it doesn't describe any flags related to the man pages, so the standard zsh build process must handle them correctly by default.
I'd suggest, as a result, that the issue isn't a matter of the zsh dev team doing something wrong, but the package maintainer doing something wrong.
First install Rust then enjoy using cargo
to install with:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Then you can easily use:
cargo install exa
cargo install fd
cargo install bat
cargo install ripgrep
cargo install procs
```
I added a couple of others that IMHO are essential as well. 😉
iTerm uses your default shell, and it looks like yours is something other than zsh.
If you're using Apple's pre-installed zsh, it's at /bin/zsh
. If you've installed the updated version via brew, it's at /usr/local/bin/zsh
. To change your shell, the new one has to be in the list when you run cat /etc/shells
. The Apple version should be there already, but the newer brew version probably isn't. If you're going to use that, run sudo echo '/usr/local/bin/zsh' >> /etc/shells
to add it. Finally to actually change your default, do that with, for example, chsh -s /usr/local/bin/zsh
.
zsh should start (with powerlevel10k) in both Terminal.app and iTerm2. If not, just make sure your command in iTerm is set to 'Login Shell' with Preferences > Profiles > whatever profile is set to default (★) > General > Command.
Try <code>zsh-autocomplete</code>. If you then add zstyle ':autocomplete:*' default-context history-incremental-search-backward
, it will start each new command line in history search mode (press ^R
to switch back to normal completion). As you can see from this asciinema, you can write any part of a history line (not just the beginning) to get a match.
>I've tried Spaceship. I think it's nice but I prefer to use my own theme. Believe it or not, one of the Spaceship devs has switched to my theme. I had a screencast somewhere comparing them. Let's see... here it is: https://asciinema.org/a/253094.
ah ok, nice!
> Perhaps someone else with more experience will suggest something, but honestly to me it seems much more preferable to edit the original file rather than dynamically patch its internals. So what you have right now is the best solution IMO.
Fair enough :) thanks for taking the time.
> I think it's great, it's minimal unlike some of the other themes. I'd recommend giving it a go if you haven't already.
I've tried Spaceship. I think it's nice but I prefer to use my own theme. Believe it or not, one of the Spaceship devs has switched to my theme. I had a screencast somewhere comparing them. Let's see... here it is: https://asciinema.org/a/253094.
> Does this mean there is something else I can try?
Perhaps someone else with more experience will suggest something, but honestly to me it seems much more preferable to edit the original file rather than dynamically patch its internals. So what you have right now is the best solution IMO.
> I cannot agree.
Interesting choice of words on your part given that you acknowledge that the statement you are disagreeing with is true. It appears that you are contesting something I haven't said.
> no user will ever notice the interruptions
They are visible in your own cast: https://asciinema.org/a/275375. They don't look too bad but they are there.
I'm glad you've made the argument that users don't notice short delays. That's exactly why I'm saying that turbo mode provides virtually no benefit to p10k users with instant prompt (except a for a tiny minority of users). The delay that turbo mode is supposed to eliminate is very difficult to notice. Why use an advanced feature that requires changing your zsh config if it doesn't provide visible benefits?
> How would you provide a prompt and still load things in background without threads?
There are still background processes.
I don't think turbo would be useful to p10k users with instant prompt (expect for a tiny few) even if loading was down completely in the background with no keyboard freezes.
> My current # of plugins is 48. Try to do it without Turbo.
Could you point me to your zshrc? I couldn't find it.
I tried it with zplugin-light
config from https://github.com/zdharma/pm-perf-test. It loads 28 plugins according to the documentation. I've replaced geometry theme with powerlevel10k and added zsh-autosuggestions. Then I've tested what happens when I start zsh and immediately start typing. Here are the results: https://asciinema.org/a/280182. If you want to reproduce this, the docker command is in the description.
I don't believe anyone could look at this and conclude that anything is slow and needs to be optimized. It's really fast. No turbo.
Here is how Zplugin Turbo mode behaves: https://asciinema.org/a/274439. I wouldn't call it cheating nor something that simple like the trick. It's a sophisticated mechanism (the Zplugin's scheduler, namely) that allows for the plugins to load in background (to the extend allowed by no-thread equipped Zsh).
This isn't an accurate description. The fastest standard alternative to gitstatus
is git status --porcelain=v2 --branch
. The latter is written in heavily optimized C, riddled with fancy tricks and caches, and it uses all available CPU cores. It also has a big advantage of having control over the format of Git object files and caches.
git status --porcelain=v2 --branch
is up to twice as fast as vcs_info
, depending on a repository. This is because vcs_info
forks a lot for no good reason. And gitstatus
is 10 times faster than git status --porcelain=v2 --branch
. There is no cheap trick that makes it so. There is no inherent advantage that gitstatus
can exploit. It just does the same work faster.
This isn't the only external tool that Powerlevel10k reimplements in order to generate fast prompt. It also reimplements nvm
, pyenv
and a handful more.
> I'm still a fan of vcs_info though. I've never had a problem with speed.
As they say, you don't know how slow your prompt is until you see how fast it can be.
There are thousands of Spaceship users out there who are satisfied with their theme performance. But once you show them https://asciinema.org/a/253094, they cannot unsee their prompt lag. 28x reduction in latency has dramatic effect on user experience.
Favorably. Powerlevel10k is backward compatible with Powerlevel9k, which makes comparison much easier. If you've already configured Powerleve9k, you can switch your theme without changing any of the configuration options and get the same prompt as before but 10-100 times faster. See it in action.
Here's my benchmark: https://asciinema.org/a/cQ3NFPT7Lc1T34y1PpWLvwOvI
​
I didn't realize my key repeat was at 30ms, so this test was with Ubuntu's minimum setting.
​
Being in a git repo doesn't change the performance measurement for p10k very much since that's 100% async, and the prompt is built in precmd, so I'm not sure how valid of a comparison that is.
It works like this on my terminal.
Have you tried looking for <Space>
binding for zsh? bindkey ' '
should print self-insert
like I did in asciicast.
Hey mate, I really want to help but I don't make much progress other than asking questions, sorry. :(
With Zplugin you can load 2 different prompt-plugins following way:
zplg ice load'!(( LINES < 15 ))' unload'!(( LINES >= 15 ))'; zplg load halfo/lambda-mod-zsh-theme zplg ice load'!(( LINES >= 15 ))' unload'!(( LINES < 15 ))'; zplg load russjohnson/angry-fly-zsh
Asciinema video of how it works.
$config <<EOCONFIG > ${srcDir}/config.swagrc
This line says: "run the program/function $config
with the following heredoc on stdin, and write the stdout of $config
to ${srcDir}/config.swagrc". If $config
is empty, then this expands to just
<<EOCONFIG > ${srcDir/config.swagrc
which implicitly passes the heredoc through cat
.
> Can I actually pipe directly into a var with the heredoc?
No. You could capture the heredoc with
config=$(cat <<- EOCONFIG LBEGIN=... ... EOCONFIG )
But you might as well use a string then.
> Any tips for keeping semblance of indentation with the heredocs? Just indent it and trim the white space?
Use <<-
, which trims tabs (but not spaces) from the front. You can even indent the terminator string.
How did you install Ruby? Did you follow the Jekyll on macOS installation instructions? Because it is odd that your $PATH includes the ~/.local
directory. Homebrew, by default, installs into /usr/local/...
(on Mac Intel) or /opt/homebrew/...
(for Apple Silicon). I'm writing a Install Ruby Mac guide and I'm trying to provide guidance for these odd situations so it would help to know.
Please note, I'm not a developer, ... just a humble designer with a knowledge of HTML & CSS ... and was able to develop very basic sites in Jekyll, but with introduction of ZSH can't seem to install Jekyll via ZSH on Mac. :(
Very well written.
I'm curious about Buffered output. What's the purpose of capturing output and reading it from __APOLLO_BUFFER_FD
?
From the doc:
zsh --version read -r -t output_string <&${__APOLLO_BUFFER_FD}
The same thing without buffering:
zsh --version | read -r output_string
The second version of the code looks simpler, has the same performance, doesn't hang if zsh --version
produces more than 8KB of output, and doesn't create the hazard of accidentally mixing outputs of different commands.
Even simpler version:
output_string=$(exec zsh --version)
This is how I would write it. It allows you to capture all output at once, which is almost always what you want. It's also faster, as it doesn't have to read characters one by one.
Unrelated to the above. Noticed a couple of bugs.
mkdir '\$(clear >&2; echo pwnd >&2; sleep 1)' && cd $_