I have a little .zshrc file to customize my terminal, and I've always wanted a fun prompt besides the default, but haven't really done much to lear...
For further actions, you may consider blocking this person and/or reporting abuse
This is a really nice trick! In trying to figure this out I ended up giving up and going with a prompt styler - the script syntax was too dense for me at the time.
If you are interested, you should check out Oh-my-posh, it's been awesome to use. Here's a pic of the prompt I've been using:
This is my custom prompt that has the current username, which shell I'm using, current directory, Node version in use, and the end with the heart is the exit code status of the last command. (turns red if the exit code is non-zero) The second line is git status and only appears if I'm in a repo.
Setting these up can be tricky though, and the nice thing about what you built is it's easier to sync between machines since it's just a script. Nothing needs to be installed. I think I'll try to do something similar to what you have for shell I use on a few places and see if it comes easier to me this time.
It's really awesome. I love this. Except I use a theme based on the paradox theme, but I added a few more sections. Being a front-end dev lately and using different node versions for different projects it's a must to see the current npm version as well... especially if
direnv
somehow messes up loading the the right version for some reason every now and then)I use this one and its pretty great out of the box
I love that you went through the bare bones configuration. I just assumed 'starship' or something like that when you mentioned it in the newsletter. This was much more cool!
Thanks!
Really nice!
I remember having a very confusing bash code to get the last exit code on my prompt and a somewhat messy code to get the git branch name and status to color it accordingly. When I decided to try zsh I was delighted to learn that it has some very usefull builtins, like
vcs_info_msg_0_
and the%?
that gets the last exit code. My prompt is not as minimalistic as yours, but I guess I'm going to go more minimal for a few days and see if I like it.Worth saying that
%0(?..%?)
will show the last exit code but only if it was not 0. You can even style it like%0(?.. %F{green} exit code: <%?> %f)
and so on.I don't know how to upload images here, please help 😅
dev-to-uploads.s3.amazonaws.com/up...
There are also some experimental things, like highlighting, underlining and putting the letter D before the branch when the local branch is ahead, behind or have diverged, but they don't seem to work all that well.
Here is the code I used to get this prompt.
I actually like a lot the different colors for different states of the repo.
gist.github.com/lucassperez/bc04af...
Oh whoa that is so cool!! Thank you for sharing!
🧙 Nice post! Would like to propose the advanced level experience of Zsh for Zsh lovers 🧙♀️
A Swiss Army Knife for Zsh - Unix Shell ⚡
z.digitalclouds.dev ⚡
Definitely going to try this now. This is something I really want to try and work out
Super helpful and easy to use. I was able to sidestep Powerlevel10k (no shame in that game, just a "little much" for me) and get a lean prompt with just what I wanted.
Thanks! Yeah simplicity was what I wanted, too.
I have just tried it and Oh gosh! my prompt looks so clean now. Thank you Cassidy.
I'm so glad it's helpful for you!
While a vanilla solution is always nice, my go-to is Prezto!
github.com/sorin-ionescu/prezto
Lot of options and themes with minimal effort :)
I've got a similar prompt w/ branch name and I never realize how much I rely on it until I'm in a place without it and have to
git branch
every 3 seconds to remember where I am 😅Great post - thanks Cassidy!
My
git st
to figure out the branch is CONSTANT if I don't have it in the prompt hahaha! Thank you!Nice post, i also did something similar for my root shell.
BTW those who wanting that jazzy snazzy cool looking terminal with all the goodness and those juicy icons, this is what y'all need github.com/romkatv/powerlevel10k
I've always added an extra line ( \n ) right before the $ at the end so that all my commands start right at the left edge of the screen. This way if I navigate down a bunch of folders, the long path names don't get in the way.
But wait, isn't the CLI supposed to be cryptic and colorless? LOL
Yes and must have that curve of crts and scan lines and stuff like it's from 1980s
Nice article, but why reinvent the wheel? How about using ohmyposh.dev/ ?
Man powerlevel10k is lit with kitty/alcattra
I truly thought this was a spam comment until I realized these are all technical terms 😆
haha 😆 but does my profile look like spam .-.
I've tried some of the other prompts mentioned here, but I have settled on Starship (starship.rs/). Highly recommended!
This looks cool thanks for sharing!
An easier way to me would be using powerlevel10K zsh theme, it has a more user-friendly configuration process.
A few folks have mentioned that now, I should check it out!
How do I change the prompt on a Mac? comment le rendre accro
Awesome, thank you!
Stopped wasting time with custom prompts when there are faster, more portable solutions, namely starship. Works with zsh, powershell, bash ... on linux, mac and windows.