{"id":241,"date":"2019-06-05T10:27:07","date_gmt":"2019-06-05T09:27:07","guid":{"rendered":"https:\/\/www.bowlerblue.com\/site\/?p=241"},"modified":"2019-06-05T10:38:41","modified_gmt":"2019-06-05T09:38:41","slug":"zsh-and-oh-my-zsh-on-cygwin","status":"publish","type":"post","link":"https:\/\/www.bowlerblue.com\/site\/zsh-and-oh-my-zsh-on-cygwin\/","title":{"rendered":"zsh and oh-my-zsh on Cygwin"},"content":{"rendered":"\n<p>I prefer to do things on the command line rather than click around on a UI (I type much faster than I can use a mouse).  And I absolutely love the <code><a rel=\"noreferrer noopener\" aria-label=\"zsh (opens in a new tab)\" href=\"https:\/\/en.wikipedia.org\/wiki\/Z_shell\" target=\"_blank\">zsh<\/a><\/code> and <code><a rel=\"noreferrer noopener\" aria-label=\"oh-my-zsh (opens in a new tab)\" href=\"https:\/\/github.com\/robbyrussell\/oh-my-zsh\" target=\"_blank\">oh-my-zsh<\/a><\/code> combination for my terminal.  I mostly use a Mac (with <code><a rel=\"noreferrer noopener\" aria-label=\"iTerm2 (opens in a new tab)\" href=\"https:\/\/www.iterm2.com\/\" target=\"_blank\">iTerm2<\/a><\/code>) and various flavours of Linux &#8211; all of which are really straight forward to set up.   But sometimes I have to use Windows &#8211; and to keep to a Unix style shell (mostly because I know the commands much better), I use <code><a href=\"https:\/\/www.cygwin.com\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Cygwin (opens in a new tab)\">Cygwin<\/a><\/code> as a shell when on Windows.<\/p>\n\n\n\n<p>There are some instructions out there on getting <code>zsh<\/code> and <code>oh-my-zsh<\/code> set up on <code>Cygwin<\/code>, but I&#8217;ve always found that I need to combine a few of them to get the right setup, and I don&#8217;t do it often enough to remember.  So I&#8217;m writing it down here &#8211; mostly for myself!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Cygwin setup<\/h2>\n\n\n\n<p>Start with a standard Cygwin installation &#8211; and I&#8217;m assuming you use the standard shortcut to start a shell that uses <code>mintty.exe<\/code>.<\/p>\n\n\n\n<p>Use the standard Cygwin installer to install the latest versions of the following packages:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>git<\/code><\/li><li><code>wget<\/code>  (or <code>curl<\/code> &#8211; you only need one of the two)<\/li><li><code>zsh<\/code><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">oh-my-zsh installation<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Launch a Cygwin shell<\/li><li>Run the appropriate <code>wget<\/code> or <code>curl<\/code> command to download and install oh-my-zsh from the <a rel=\"noreferrer noopener\" aria-label=\"standard instructions (opens in a new tab)\" href=\"https:\/\/github.com\/robbyrussell\/oh-my-zsh\" target=\"_blank\">standard instructions<\/a>.<ul><li>With <code>wget<\/code><ul><li><code>sh -c \"$(wget -O- https:\/\/raw.githubusercontent.com\/robbyrussell\/oh-my-zsh\/master\/tools\/install.sh)\"<\/code><\/li><\/ul><\/li><li>With <code>curl<\/code><ul><li><code>sh -c \"$(curl -fsSL https:\/\/raw.githubusercontent.com\/robbyrussell\/oh-my-zsh\/master\/tools\/install.sh)\"<\/code><\/li><\/ul><\/li><\/ul><\/li><li>Exit the shell<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Make zsh the default<\/h2>\n\n\n\n<p>You now have <code>zsh<\/code> and <code>oh-my-zsh<\/code> installed, but the default shell (when you double-click the icon) will still be <code>bash<\/code> (you need to execute <code>zsh<\/code> to change to it).  Lets make <code>zsh<\/code> the default shell for your shortcut icon.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Right click the icon you use to launch Cygwin and select <code>Properties<\/code>.<\/li><li>In the Target field, change it to the following (replacing <code>&lt;cygwin-folder&gt;<\/code> with the actual folder where Cygwin is installed):<ul><li><code>c:\\&lt;cygwin-folder&gt;\\bin\\mintty.exe -i \/Cygwin-Terminal.ico \/usr\/bin\/zsh --login -<\/code><\/li><li>(The important bits where adding here is <code>\/usr\/bin\/zsh --login -<\/code> if you miss the <code>--login<\/code> part the shell will misbehave and not find a lot of executables).<\/li><\/ul><\/li><li>Try it out &#8211; if you now run a shell and execute <code>echo $SHELL<\/code> you should get back <code>\/bin\/zsh<\/code><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Customise oh-my-zsh<\/h2>\n\n\n\n<p>You can now customise zsh and oh-my-zsh as usual by modifying the contents of <code>.zshrc<\/code> in your (Cygwin) home directory.  If you must know, I use either the <code><a rel=\"noreferrer noopener\" aria-label=\"agnoster (opens in a new tab)\" href=\"https:\/\/github.com\/agnoster\/agnoster-zsh-theme\" target=\"_blank\">agnoster<\/a><\/code> theme, or a heavily customised version of <code><a rel=\"noreferrer noopener\" aria-label=\"powerlevel9k (opens in a new tab)\" href=\"https:\/\/github.com\/bhilburn\/powerlevel9k\" target=\"_blank\">powerlevel9k<\/a><\/code> &#8211; they both have fantastic <code>git<\/code> support.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Powerline fonts<\/h3>\n\n\n\n<p>Some of these themes (and both that I mention above) require the <code><a rel=\"noreferrer noopener\" aria-label=\"Powerline (opens in a new tab)\" href=\"https:\/\/github.com\/powerline\/fonts\" target=\"_blank\">Powerline<\/a><\/code> fonts to be installed to get special characters.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>In a Cygwin shell, in your home directory, execute <code>git clone https:\/\/github.com\/powerline\/fonts.git --depth=1<\/code><\/li><li>Close the Cygwin shell.<\/li><li>Open Windows PowerShell as an Administrator (<code>Window Key + X<\/code> then select &#8220;Windows PowerShell (Admin)&#8221; and select &#8220;Yes&#8221;.)  Change back to the directory where the &#8220;fonts&#8221; repository was downloaded (e.g. <code>cd \\&lt;cygwin-dir&gt;\\home\\&lt;myuser&gt;\\fonts<\/code>).<\/li><li>In the PowerShell, execute <code>Set-ExecutionPolicy Bypass<\/code> &#8211; accept the warning.<\/li><li>Execute <code>.\\install.ps1<\/code> &#8211; this will run the PowerShell script to install the fonts &#8211; it will take a while.<\/li><li>When done, reset your execution policy by executing <code>Set-ExecutionPolicy Default<\/code> and accept the warning.<\/li><li>You can now change the font in your <code>mintty.exe<\/code> setup to use a Powerline font. <\/li><\/ul>\n\n\n\n<p>This shows a screenshot with colour scheme &#8220;dracula&#8221;, transparency set to &#8220;Medium&#8221;, font &#8220;Noto Mono for Powerline&#8221; 9pt.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"598\" height=\"385\" src=\"https:\/\/www.bowlerblue.com\/site\/wp-content\/uploads\/2019\/06\/oh-my-zsh-cygwin.png\" alt=\"\" class=\"wp-image-249\" srcset=\"https:\/\/www.bowlerblue.com\/site\/wp-content\/uploads\/2019\/06\/oh-my-zsh-cygwin.png 598w, https:\/\/www.bowlerblue.com\/site\/wp-content\/uploads\/2019\/06\/oh-my-zsh-cygwin-300x193.png 300w\" sizes=\"auto, (max-width: 598px) 100vw, 598px\" \/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I prefer to do things on the command line rather than click around on a UI (I type much faster than I can use a mouse). And I absolutely love the zsh and oh-my-zsh combination for my terminal. I mostly use a Mac (with iTerm2) and various flavours of Linux &#8211; all of which are [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-241","post","type-post","status-publish","format-standard","hentry","category-code"],"_links":{"self":[{"href":"https:\/\/www.bowlerblue.com\/site\/wp-json\/wp\/v2\/posts\/241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bowlerblue.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bowlerblue.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bowlerblue.com\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bowlerblue.com\/site\/wp-json\/wp\/v2\/comments?post=241"}],"version-history":[{"count":8,"href":"https:\/\/www.bowlerblue.com\/site\/wp-json\/wp\/v2\/posts\/241\/revisions"}],"predecessor-version":[{"id":251,"href":"https:\/\/www.bowlerblue.com\/site\/wp-json\/wp\/v2\/posts\/241\/revisions\/251"}],"wp:attachment":[{"href":"https:\/\/www.bowlerblue.com\/site\/wp-json\/wp\/v2\/media?parent=241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bowlerblue.com\/site\/wp-json\/wp\/v2\/categories?post=241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bowlerblue.com\/site\/wp-json\/wp\/v2\/tags?post=241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}