{"id":288,"date":"2020-04-26T16:46:47","date_gmt":"2020-04-26T23:46:47","guid":{"rendered":"https:\/\/www.tizianasellitto.it\/blog\/?p=288"},"modified":"2020-05-11T09:47:56","modified_gmt":"2020-05-11T16:47:56","slug":"from-bash-to-zsh-git-and-prompt-configuration","status":"publish","type":"post","link":"https:\/\/www.tizianasellitto.it\/blog\/?p=288","title":{"rendered":"From bash to zsh&#8230;git and prompt configuration"},"content":{"rendered":"\n<p class=\"has-text-align-justify\">After a really long journey I decided to retire my long-lasting and trustworthy companion, my 2012 MacBook Air. I spent quite some time to decide which new model to buy; in the end the presence of the touch bar made me avoid all other models and going for the latest 2020 MacBook Air.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">I didn&#8217;t want to use one of my time capsule backup but have a new clean env to setup and so first thing first:  <em>git<\/em>, <em>bash-completion <\/em>and customization of the <em>prompt<\/em> on zsh shell on macOs Catalina. I used brew to do it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">brew install git bash-completion<\/pre>\n\n\n\n<p class=\"has-text-align-justify\">And then to make the completion available in&nbsp;<code>zsh<\/code> as suggested by <a href=\"https:\/\/docs.brew.sh\/Shell-Completion\" target=\"_blank\" rel=\"noreferrer noopener\">homebrew<\/a> website you must get the Homebrew-managed zsh site-functions on your&nbsp;<code>FPATH<\/code>&nbsp;before initialising&nbsp;<code>zsh<\/code>\u2019s completion facility, so I added the following in the&nbsp;<code>~\/.zshrc<\/code>&nbsp;file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">if type brew &amp;&gt;\/dev\/null; then\n  FPATH=$(brew --prefix)\/share\/zsh\/site-functions:$FPATH\n  autoload -Uz compinit &amp;&amp; compinit\nfi<\/pre>\n\n\n\n<p class=\"has-text-align-justify\">Compinit was complaining about insecure directories, so I listed the insecure directory and added the correct permission for those.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">zsh compinit: insecure directories, run compaudit for list.\nIgnore insecure directories and continue [y] or abort compinit [n]? \n\ncompaudit\n\nThis is because those folders are group writable, so I changes it:\n\ncompaudit | xargs chmod g-w<\/pre>\n\n\n\n<p class=\"has-text-align-justify\">I do like do see in my prompt both the <em>user<\/em> and the <em>machine name<\/em>, the <em>path<\/em> I&#8217;m on and if it&#8217;s a git repository the <em>branch name<\/em> and adding some color. Next step will be adding some more icon to show the status of the git repository.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Load version control information\nautoload -Uz vcs_info\nprecmd() { vcs_info }\n\n# Format the vcs_info_msg_0_ variable\nzstyle ':vcs_info:git:*' formats '(%b)'\n\nautoload -U colors &amp;&amp; colors\n\n# Set up the prompt (with git branch name)\nsetopt PROMPT_SUBST\nPROMPT='%n@%m %F{green}${PWD\/#$HOME\/~}%f %F{yellow}${vcs_info_msg_0_}%f > '<\/pre>\n\n\n\n<div class=\"wp-block-image is-style-rounded\"><figure class=\"alignleft size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/www.tizianasellitto.it\/blog\/wp-content\/uploads\/2020\/04\/Screen-Shot-2020-04-26-at-4.43.52-PM.png\" alt=\"zsh custom prompt\" class=\"wp-image-305\" width=\"663\" height=\"76\" srcset=\"https:\/\/www.tizianasellitto.it\/blog\/wp-content\/uploads\/2020\/04\/Screen-Shot-2020-04-26-at-4.43.52-PM.png 956w, https:\/\/www.tizianasellitto.it\/blog\/wp-content\/uploads\/2020\/04\/Screen-Shot-2020-04-26-at-4.43.52-PM-300x35.png 300w, https:\/\/www.tizianasellitto.it\/blog\/wp-content\/uploads\/2020\/04\/Screen-Shot-2020-04-26-at-4.43.52-PM-768x88.png 768w, https:\/\/www.tizianasellitto.it\/blog\/wp-content\/uploads\/2020\/04\/Screen-Shot-2020-04-26-at-4.43.52-PM-624x72.png 624w\" sizes=\"(max-width: 663px) 100vw, 663px\" \/><figcaption>work in progress of my zsh prompt customization<\/figcaption><\/figure><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>After a really long journey I decided to retire my long-lasting and trustworthy companion, my 2012 MacBook Air. I spent quite some time to decide which new model to buy; in the end the presence of the touch bar made me avoid all other models and going for the latest 2020 MacBook Air. I didn&#8217;t [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[19,14],"tags":[32,17,33],"_links":{"self":[{"href":"https:\/\/www.tizianasellitto.it\/blog\/index.php?rest_route=\/wp\/v2\/posts\/288"}],"collection":[{"href":"https:\/\/www.tizianasellitto.it\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tizianasellitto.it\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tizianasellitto.it\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tizianasellitto.it\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=288"}],"version-history":[{"count":15,"href":"https:\/\/www.tizianasellitto.it\/blog\/index.php?rest_route=\/wp\/v2\/posts\/288\/revisions"}],"predecessor-version":[{"id":309,"href":"https:\/\/www.tizianasellitto.it\/blog\/index.php?rest_route=\/wp\/v2\/posts\/288\/revisions\/309"}],"wp:attachment":[{"href":"https:\/\/www.tizianasellitto.it\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tizianasellitto.it\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tizianasellitto.it\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}