ZSH profile

You know https://github.com/dylanaraps/neofetch?
It has a lot of overhead within and it's slow, IMHO.

screenshot-2024-10-01-at-17.28.46

So I made my own small one. It shows path, time, success indication for the last command (time in red/green), git branch, coloured dirs, emoticons for every shell to indicate where a drop table * is OK, and wisdom. It's just a WIP'n'boilerplate for more.

How?

Create two files in your MacOS home directory called .zshrc and quotes.txt with the following content:

.zshrc

export PATH="/usr/local/opt/openjdk/bin:$PATH"
export CLICOLOR=1

# info=`uname -v`
infoMac=`sysctl -n hw.model`
infoMac+=`printf " "`
infoMac+=`sysctl -n machdep.cpu.brand_string`
infoDevice=`uname -n`
infoMachine=`uname -m`
infoKernel=`uname -s`
infoKernelVersion=`uname -r`
infoUptime=`uptime | sed -E 's/^[^,]*up *//; s/, *[[:digit:]]* users.*//; s/min/minutes/; s/([[:digit:]]+):0?([[:digit:]]+)/\1h \2m/'`
infoOS=`sw_vers -productName`
infoOS+=`printf " "`
infoOS+=`sw_vers -productVersion`
infoOS+=`sw_vers -buildVersion`
infoUsers=`who | grep -c .`
quote=`sort -R ~/quotes.txt | head -n1`

icons="๐Ÿถ๐Ÿญ๐Ÿฐ๐ŸฆŠ๐Ÿป๐Ÿผ๐Ÿฏ๐Ÿฆ๐Ÿฎ๐Ÿท๐Ÿธ๐Ÿต๐Ÿฆ„๐Ÿ๐Ÿž๐ŸŒฒ๐ŸŒณ๐ŸŒด๐Ÿ๐Ÿ„๐Ÿ”ฅ๐ŸŒˆ๐Ÿ๐ŸŽ๐ŸŠ๐Ÿž๐Ÿฟ๐Ÿฅซ๐Ÿบโšฝ๏ธ๐Ÿ€๐Ÿˆ๐ŸŽฑ๐ŸŽน๐ŸŽฒ๐Ÿ“บโฐ๐Ÿงป๐Ÿ“ฆ๐Ÿ‘ฝ๐Ÿ‘พ๐Ÿค–๐Ÿง ๐Ÿš€๐Ÿ—ฟ"
icon="${icons:$(( RANDOM % ${#icons} )):1}" # pick a 1 char substring starting at a random position

echo "
\033[38;5;034m                    โ–‘โ–‘โ–‘โ–‘
\033[38;5;034m                 โ–‘โ–’โ–“โ–ˆโ–’โ–‘
\033[38;5;034m                โ–‘โ–’โ–“โ–ˆโ–’โ–‘
\033[38;5;034m               โ–‘โ–’โ–ˆโ–“โ–’โ–‘
\033[38;5;034m     โ–‘โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–‘  โ–‘โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–‘
\033[38;5;034m   โ–‘โ–’โ–“โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–“โ–‘โ–‘โ–“โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–’โ–‘
\033[38;5;226m โ–‘โ–’โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–’โ–’โ–‘   \033[1;90m $infoMac
\033[38;5;226m โ–‘โ–“โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–’โ–‘     \033[1;90m $infoOS
\033[38;5;208mโ–‘โ–“โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–“โ–‘      \033[1;90m $infoKernel Kernel
\033[38;5;208mโ–‘โ–“โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–“โ–‘      \033[1;90m Version $infoKernelVersion $infoโ–ˆachine
\033[38;5;196mโ–‘โ–“โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–’โ–‘     \033[1;90m $infoUsers Users
\033[38;5;196m โ–‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–’โ–’โ–‘   \033[1;90m Uptime $infoUptime
\033[38;5;129m โ–‘โ–’โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–“โ–‘
\033[38;5;129m  โ–‘โ–’โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–’โ–‘
\033[38;5;038m    โ–‘โ–“โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–“โ–‘
\033[38;5;038m     โ–‘โ–’โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–“โ–’โ–‘โ–‘โ–’โ–“โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–’โ–‘  \033[1;90m Welcome \033[1;97m$USER
\033[38;5;038m       โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘    โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘  \033[1;90m   on \033[1;97m$infoDevice\033[1;90m!
\033[1;97m"

echo "\e[30;48;5;82m ๐Ÿ’ฌ $quote \e[0m\n"

# โ–ˆ โ–‰ โ–Š โ–‹ โ–Œ โ– โ–Ž โ–โ– โ–• โ–‡ โ–† โ–… โ–„ โ–ƒ โ–‚ โ–  โ–  โ–„ โ–€  โ–ฌ โ–“ โ–’ โ–‘
# echo  โ–ˆโ–‰โ–Šโ–‹โ–Œโ–โ–Žโ– โ–‡โ–†โ–…โ–„โ–ƒโ–‚โ–  โ– โ–„โ–€โ–ฌโ–“โ–’โ–‘

alias ls='ls -Ga'
alias ll='ls -laG'
alias vc='code'
alias c='cd ..'

# https://dev.to/cassidoo/customizing-my-zsh-prompt-3417
# http://mvisser.github.io/2011/07/20/zsh-and-git.html

autoload -Uz vcs_info
precmd() { vcs_info }

zstyle ':vcs_info:git:*' formats '%b '

# https://stackoverflow.com/a/70712312
# PROMPT='%F{green}%*%f %F{blue}%~%f %F{red}${vcs_info_msg_0_}%f$ '
# PS1='%B%F{red}[%F{yellow}%n%F{green}@%F{blue}%M '
# PS1='%F{green}%*%f %F{blue}%~%f %F{red}${vcs_info_msg_0_}%f$ '
# PS1+='%F{magenta}%~%F{red}] %(?.%F{green}.%F{red})โžœ%b%f '
# โžœ โ‡จ โญ† โฎ• โ–ถ
# PS1+='%(?.%F{green}.%F{red})โ–ถ%b%f %f$ '

setopt PROMPT_SUBST
NEWLINE=$'\n'
PROMPT='โ•ญโ”€$icon %(?.%F{green}.%F{red})%*%f %F{blue}%~%f %F{magenta}${vcs_info_msg_0_}%f${NEWLINE}โ•ฐโ”€$ '

# export PATH=".:/opt/xyz/bin:$PATH" or
# export PATH=".:$PATH:/opt/xyz/bin"

quotes.txt

Know how to learn. Then, want to learn. (Katherine Johnson)
Good software, like wine, takes time. ๐Ÿท (Joel Spolsky)
Programs must be written for people to read, and only incidentally for machines to execute. (Harold Abelson)
Talk is cheap. Show me the code. (Linus Torvalds)
Every program has two purposes: The one for which it was written and another for which it wasn't. (Alan J. Perlis)
Every great developer you know got there by solving problems they were unqualified to solve until they actually did it. (Patrick McKenzie)
One of my most productive days was throwing away 1000 lines of code. (Ken Thompson)
In theory, there is no difference between theory and practice. But, in practice, there is. (Jan L. A. van de Snepscheut)
If something is expensive to develop, and somebody's not going to get paid, it won't get developed. So you decide: Do you want software to be written, or not? (Bill Gates)
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. (Martin Fowler)
Before software can be reusable it first has to be usable. (Ralph Johnson)
Inside every large program, there is a small program trying to get out. (C. A. R. Hoare)
Functional programming is a radical and elegant attack on the whole enterprise of writing programs. It's very different from the 'do this and then do that' programming mentality. You have to rewire your brain in quite a different way. (Simon Peyton-Jones)
Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function. (John Carmack)
A program is like a poem: you cannot write a poem without writing it. (E. W. Dijkstra)
You might not think that programmers are artists, but programming is an extremely creative profession. Its logic-based creativity. (John Romero)
Be curious. Read widely. Try new things. I think a lot of what people call intelligence boils down to curiosity. (Aaron Swartz)
Measuring programming progress by lines of code is like measuring aircraft building progress by weight. (Bill Gates)
The cleaner and nicer the program, the faster itโ€™s going to run. And if it doesnโ€™t, itโ€™ll be easy to make it fast. (Joshua Bloch)
Code is like humor. When you have to explain it, itโ€™s bad. (Cory House)
Programming isnโ€™t about what you know; itโ€™s about what you can figure out. (Chris Pine)
People have an enormous tendency to resist change. They love to say, 'We've always done it this way.' I try to fight that. (Grace Hopper)
Itโ€™s not at all important to get it right the first time. Itโ€™s vitally important to get it right the last time. (The Pragmatic Programmer)
The best error message is the one that never shows up. (Thomas Fuchs)
Computers are good at following instructions, but not at reading your mind. (Donald Knuth)
Simplicity is about subtracting the obvious and adding the meaningful. (John Maeda)
Never trust a computer you canโ€™t throw out a window. (Steve Wozniak)
Programming is not easy like Sunday morning, it is silent poetry. (Waseem Latif)
Everyday life is like programming, I guess. If you love something you can put beauty into it. (Donald Knuth)
The best way to predict the future is to implement it. (Alan Kay)
If someone claims to have the perfect programming language, [s]he is either a fool or a salesman or both. (Bjarne Stroustrup)
It is not the language that makes programs appear simple. It is the programmer that make the language appear simple! (Uncle Bob)
Testing leads to failure, and failure leads to understanding. (Burt Rutan)
Everyday life is like programming, I guess. If you love something you can put beauty into it. (Donald Knuth)
Programming: when the ideas turn into the real things. (Maciej Kaczmarek)
Always implement things when you actually need them, never when you just foresee that you need them. (Ron Jeffries)
Programming is not easy like Sunday morning, it is silent poetry. (Waseem Latif)
Thatโ€™s whatโ€™s cool about working with computers. They donโ€™t argue, they remember everything and they donโ€™t drink all your beer. (Paul Leary)
Telling a programmer there's already a library to do X is like telling a songwriter there's already a song about love. (Pete Cordell)
Fancy algorithms are slow when n is small, and n is usually small. (Rob Pike)
Programming languages, like pizza, come in only two sizes: too big and too small. (Richard Pattis)
Simplicity carried to the extreme becomes elegance. (Jon Franklin)
Without requirements or design , programming is the art of adding bugs to an empty text file. (Louis Srygley)
What I cannot build, I do not understand. (Richard Feynman)
Deleted code is debugged code. (Jeff Sickel)
The object-oriented version of spaghetti code is, of course, 'lasagna code'. Too many layers. (Roberto Waltman)
So much complexity in software comes from trying to make one thing do two things. (Ryan Singer)
There's nothing more permanent than a temporary hack. (Kyle Simpson)
An evolving system increases its complexity unless work is done to reduce it. (Meir Lehman)
No one in the brief history of computing has ever written a piece of perfect software. It's unlikely that you'll be the first. (Andy Hunt)
Good design adds value faster than it adds cost. (Thomas C. Gale)
One of the best programming skills you can have is knowing when to walk away for awhile. (Oscar Godson)
Every good idea will be discovered twice: once by a logician and once by a computer scientist. (Philip Wadler)
Make it correct, make it clear, make it concise, make it fast. In that order. (Wes Dyer)
Code is like humor. When you have to explain it, itโ€™s bad. (Cory House)
Languages shape the way we think, or don't. (Erik Naggum)
A program is never less than 90% complete, and never more than 95% complete. (Terry Baker)
People have an enormous tendency to resist change. They love to say, 'We've always done it this way.' I try to fight that. (Grace Hopper)
Commenting your code is like cleaning your bathroom - you never want to do it, but it really does create a more pleasant experience for you and your guests. (Ryan Campbell)
Sometimes the idea behind a program is one small creative effort. Just like in a short story, one little twist in the plot is the whole idea behind it. (Dan Bricklin)
Sometimes the problem is to discover what the problem is. (Gordon Glegg)
Those hours of practice, and failure, are a necessary part of the learning process. (Gina Sipley)
The only way to learn a new programming language is by writing programs in it. (Dennis Ritchie)
Don't patch bugs out, rewrite them out. (Anonymous)
No code is faster than no code. (Merb Motto)
Treat your code like poetry and take it to the edge of the bare minimum. (ILYO)
We build our computer (systems) the way we build our cities: over time, without a plan, on top of ruins. (Ellen Ullman)
Sometimes it's better to leave something alone, to pause, and that's very true of programming. (Joyce Wheeler)
In programming the hard part isnโ€™t solving problems, but deciding what problems to solve. (Paul Graham)
Every great developer you know got there by solving problems they were unqualified to solve until they actually did it. (Patrick McKenzie)
If it doesnโ€™t work, it doesnโ€™t matter how fast it doesnโ€™t work. (Mich Ravera)
In the end, regardless of where you are on the development hierarchy, keep coding. Itโ€™s where youโ€™re most valuable. (The Developer's Code)
The key to eโ€‹fficient development is to 'make interesting new mistakes'. (Tom Love)
The best way to get the right answer [..] is not to ask a question; itโ€™s to post the wrong answer. (Cunninghamโ€™s Law)
Always implement things when you actually need them, never when you just foresee that you need them. (Ron Jeffries)
If you can get todayโ€™s work done today, but you do it in such a way that you canโ€™t possibly get tomorrowโ€™s work done tomorrow, then you lose. (Martin Fowler)
Documentation is a love letter that you write to your future self. (Damian Conway)
A user interface should be so simple that a beginner in an emergency can understand it within ten seconds. (Ted Nelson)
Thereโ€™s a big difference between making a simple product & making a product simple. (Des Traynor)
The only thing more frightening than a programmer with a screwdriver or a hardware engineer with a program is a user with a pair of wire cutters and the root password. (Elizabeth Zwicky)
Debuggers don't remove bugs. They only show them in slow motion. (Unknown)
A computer is like a mischievous genie. It will give you exactly what you ask for, but not always what you want. (Joe Sondow)
Beware of bugs in the above code; I have only proved it correct, not tried it. (Donald Knuth)
Donโ€™t document the problem, fix it. (Atli Bjรถrgvin Oddsson)
If you donโ€™t actively attack the risks, the risks will actively attack you. (Tom Gilb)
The first step of any project is to grossly underestimate its complexity and difficulty. (Nicoll Hunt)
Blame the implementation, not the technique. (Tim Kadlec)
A primary cause of complexity is that software vendors uncritically adopt almost any feature that users want. (Niklaus Wirth)
The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. (Ted Nelson)
Be curious. Read widely. Try new things. I think a lot of what people call intelligence boils down to curiosity. (Aaron Swartz)
Codes are a puzzle. A game, just like any other game. (Alan Turing)
Falling in love with code means falling in love with problem solving and being a part of a forever ongoing conversation. (Kathryn Barrett)
I have not failed, but found 1000 ways to not make a light bulb. (Thomas A. Edison)
Everyone wants the project to be good, fast, and cheap... pick two. (Unknown)
The engineer has been, and is, a maker of history. (James Kip Finch)
Engineering is achieving function while avoiding failure. (Henry Petroski)
The scientist discovers a new type of material or energy and the engineer discovers a new use for it. (Gordon Lindsay Glegg)
Once a new technology rolls over you, if you're not part of the steamroller, you're part of the road. (Stewart Brand)
The production of too many useful things results in too many useless people. (Karl Marx)
Technology is ruled by two types of people: those who manage what they do not understand, and those who understand what they do not manage. (Mike Trout)
Technology makes it possible for people to gain control over everything, except over technology. (John Tudor)
Technology is like a fish. The longer it stays on the shelf, the less desirable it becomes. (Andrew Heller)
Humanity is acquiring all the right technology for all the wrong reasons. (R. Buckminster Fuller)
It's not computer literacy that we should be working on, but sort of human literacy. Computers have to become human-literate. (Nicholas P. Negroponte)
A computer will do what you tell it to do, but that may be much different from what you had in mind. (Joseph Weizenbaum)
It has become appallingly obvious that our technology has exceeded our humanity. (Albert Einstein)
Man is a slow, sloppy and brilliant thinker; the machine is fast, accurate and stupid. (William M. Kelly)
The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. (Isaac Asimov)
The factory of the future will have only two employees, a man, and a dog. The man will be there to feed the dog. The dog will be there to keep the man from touching the equipment. (Warren G. Bennis)
The trouble with programmers is that you can never tell what a programmer is doing until itโ€™s too late. (Seymour Cray)
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. (Brian W. Kernighan)