{"id":2318,"date":"2020-07-07T03:57:48","date_gmt":"2020-07-07T07:57:48","guid":{"rendered":"http:\/\/www.rexfeng.com\/blog\/?p=2318"},"modified":"2020-07-07T03:57:48","modified_gmt":"2020-07-07T07:57:48","slug":"zsh-ps1-setup","status":"publish","type":"post","link":"https:\/\/www.rexfeng.com\/blog\/2020\/07\/zsh-ps1-setup\/","title":{"rendered":"zsh PS1 setup"},"content":{"rendered":"\n<p>macOS Catalina uses zsh as the new default shell (instead of bash) in Terminal. This means that many people will be looking to re-setup their CLI with <code>~\/.zshrc<\/code> instead of <code>~\/.bash_profile<\/code>.<\/p>\n\n\n\n<p>While customizing my .zshrc was a hassle, it was also an opportunity to clean up my profile and remove legacy settings.<\/p>\n\n\n\n<p>Zsh offers an optional right side prompt, but I only used the left side prompt for now.<\/p>\n\n\n\n<p>Here are some misc tips that I&#8217;ve found helpful:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>For basic PS1 exports (time\/date, current dir, user, etc), you can find<a href=\"http:\/\/zsh.sourceforge.net\/Doc\/Release\/Prompt-Expansion.html#Prompt-Expansion\"> examples here<\/a>. Things like <code>%D<\/code> for the current date, <code>%~<\/code> for the current directoy, and more.<\/li><li>In your PS1 export, you can start color formatting with <code>%F{117}<\/code> and end color formatting with <code>%f<\/code>. Replace 117 with whatever color your desire. You can find <a href=\"https:\/\/jonasjacek.github.io\/colors\/\">color codes here<\/a>.<\/li><li>You can make your tab auto completion case insensitive (ignore case) by adding:<br><code><span class=\"has-inline-color has-vivid-cyan-blue-color\">zstyle ':completion:*' matcher-list 'm:{[:lower:]}={[:upper:]}'<br>autoload -Uz compinit &amp;&amp; compinit -i<\/span><\/code><\/li><li>You can show your current git branch with:<br><code><span class=\"has-inline-color has-vivid-cyan-blue-color\">autoload -Uz vcs_info<br>precmd() { vcs_info }<br>zstyle ':vcs_info:git:*' formats '(%b)'<br>setopt prompt_subst<\/span><\/code><br>Note: you also need to add <code>$vcs_info_msg_0_<\/code> in your PS1 export line.<\/li><\/ul>\n\n\n\n<p>I&#8217;ve thought about creating a zshrc WYSIWYG tool, ala <a href=\"https:\/\/xta.github.io\/HalloweenBash\/\">Halloween Bash<\/a>, but I&#8217;ve shelved those plans since there&#8217;s only so much time in a day. With macOS Catalina inevitable for macOS users, more and more people are going to be looking for easy <code>~\/.zshrc<\/code> customization.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>macOS Catalina uses zsh as the new default shell (instead of bash) in Terminal. This means that many people will be looking to re-setup their CLI with ~\/.zshrc instead of ~\/.bash_profile. While customizing my .zshrc was a hassle, it was also an opportunity to clean up my profile and remove legacy settings. Zsh offers an [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,1029],"tags":[1450,1448,524,1405,1449,797,1451],"class_list":["post-2318","post","type-post","status-publish","format-standard","hentry","category-culture","category-programming","tag-bash","tag-catalina","tag-mac","tag-macos","tag-shell","tag-terminal","tag-zsh"],"_links":{"self":[{"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/posts\/2318","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/comments?post=2318"}],"version-history":[{"count":4,"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/posts\/2318\/revisions"}],"predecessor-version":[{"id":2322,"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/posts\/2318\/revisions\/2322"}],"wp:attachment":[{"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/media?parent=2318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/categories?post=2318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/tags?post=2318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}