{"id":1650,"date":"2017-12-28T22:40:40","date_gmt":"2017-12-28T20:40:40","guid":{"rendered":"http:\/\/142.93.241.207\/?p=1650"},"modified":"2017-12-29T20:20:32","modified_gmt":"2017-12-29T18:20:32","slug":"developing-for-openfoam-on-windows-10-part-4","status":"publish","type":"post","link":"https:\/\/www.albertopassalacqua.com\/?p=1650","title":{"rendered":"Developing for OpenFOAM on Windows 10 \u2013 Part 4"},"content":{"rendered":"<h3>Customizing colors in the WSL terminal<\/h3>\n<p style=\"text-align: justify;\">The default colors in the Ubuntu WSL terminal are not very readable. In particular, the blue color does not read well on the black background. While it is possible to customize colors in bash, a simpler workaround is to change colors using the Windows settings. To do this, click on the Ubuntu logo in the top-left corner of the WSL terminal window, and select Properties.<\/p>\n<p><a href=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_20.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1663\" src=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_20-283x300.png\" alt=\"\" width=\"380\" height=\"403\" srcset=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_20-283x300.png 283w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_20-768x813.png 768w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_20-967x1024.png 967w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_20.png 1208w\" sizes=\"auto, (max-width: 380px) 100vw, 380px\" \/><\/a><\/p>\n<p>This will open a dialog box with the specific settings to customize the launcher of the Ubuntu WSL terminal:<\/p>\n<p><a href=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_21.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1665\" src=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_21-279x300.png\" alt=\"\" width=\"374\" height=\"402\" srcset=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_21-279x300.png 279w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_21-768x825.png 768w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_21-953x1024.png 953w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_21.png 1036w\" sizes=\"auto, (max-width: 374px) 100vw, 374px\" \/><\/a><\/p>\n<p>Choose the &#8220;Colors&#8221; tab, and set:<\/p>\n<ul>\n<li>Screen text: Black<\/li>\n<li>Screen background: White<\/li>\n<li>Popup background: leave unchanged (purple)<\/li>\n<li>Popup background: White<\/li>\n<\/ul>\n<p>This will make the terminal more readable, at least according to my preferences.<\/p>\n<h3 style=\"text-align: justify;\">Editing code from Windows and compile it in WSL<\/h3>\n<p style=\"text-align: justify;\">Editing files in WSL from both Windows and Linux is possible if the files are stored on the Windows file system. However, some care must be taken to avoid troubles. Before proceeding, please read <a href=\"https:\/\/blogs.msdn.microsoft.com\/commandline\/2016\/11\/17\/do-not-change-linux-files-using-windows-apps-and-tools\/\">this blog post<\/a>, which clarifies the important points. More technical details are available <a href=\"https:\/\/blogs.msdn.microsoft.com\/wsl\/2016\/06\/15\/wsl-file-system-support\/\">here<\/a>.<\/p>\n<p style=\"text-align: justify;\">The easy way to edit code in Windows, and use it in WSL is to store the code in a directory on Windows. Any directory in Windows drives (<code>C:\\<\/code> etc) is fine. These drives are automatically mounted in WSL, and accessible at the path\u00a0<code>\/mnt\/&lt;drive_letter&gt;\/<\/code>. For example, the C:\\ drive is accessible to the Linux system running in WSL at the path <code>\/mnt\/c\/<\/code><\/p>\n<p style=\"text-align: justify;\">One simple approach is to create a folder in <code>C:\\<\/code>, which, in my case, I called <code>SharedWSL<\/code>, as shown below.<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_19.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1670\" src=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_19-300x248.png\" alt=\"\" width=\"591\" height=\"489\" srcset=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_19-300x248.png 300w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_19-768x634.png 768w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_19-1024x846.png 1024w\" sizes=\"auto, (max-width: 591px) 100vw, 591px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">The directory is accessible in the WSL terminal at <code>\/mnt\/c\/SharedWSL<\/code> and it is writable by both operating systems.<\/p>\n<p style=\"text-align: justify;\">It is convenient to create a shortcut on the Windows desktop to easily access this directory from the Windows environment. To achieve this, right click on the SharedWSL folder, and select &#8220;Create shortcut&#8221;. <a href=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_24.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1674\" src=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_24-300x300.png\" alt=\"\" width=\"517\" height=\"517\" srcset=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_24-300x300.png 300w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_24-150x150.png 150w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_24-768x770.png 768w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_24-1022x1024.png 1022w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_24-100x100.png 100w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_24.png 1918w\" sizes=\"auto, (max-width: 517px) 100vw, 517px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">Windows will inform you that it cannot create one in <code>C:\\<\/code>, and offer the option to create it on your desktop. Accept to complete the operation.<\/p>\n<h3>Setting up your Windows text editor to save files properly in the WSL operating system<\/h3>\n<p>It is recommended to use a text editor which can save files with UNIX end of line. Most of the text editors let the user select this option. Here settings for Notepad++ are shown.<\/p>\n<p>Notepad++ offers two ways to select the UNIX (LF) option:<\/p>\n<ol>\n<li><em>Global setting<\/em> in the Settings -&gt; Preferences&#8230; menu, under the &#8220;New document&#8221; tab:<a href=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_22.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1671\" src=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_22-300x237.png\" alt=\"\" width=\"657\" height=\"519\" srcset=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_22-300x237.png 300w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_22-768x607.png 768w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_22-1024x809.png 1024w\" sizes=\"auto, (max-width: 657px) 100vw, 657px\" \/><\/a><\/li>\n<li>On a <em>per-file basis<\/em>, at the bottom of the notification area of the editor, boxed in red in the figure<a href=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_23.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1672\" src=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_23-300x138.png\" alt=\"\" width=\"587\" height=\"270\" srcset=\"https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_23-300x138.png 300w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_23-768x353.png 768w, https:\/\/www.albertopassalacqua.com\/wp-content\/uploads\/2017\/12\/WSL_23-1024x471.png 1024w\" sizes=\"auto, (max-width: 587px) 100vw, 587px\" \/><\/a><\/li>\n<\/ol>\n<p style=\"text-align: justify;\">Enjoy\u00a0 <img src=\"https:\/\/www.albertopassalacqua.com\/wp-includes\/images\/smilies\/mrgreen.png\" alt=\":mrgreen:\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/><\/p>\n<p style=\"text-align: justify;\"><em>This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM\u00ae and OpenCFD\u00ae trade marks. Alberto Passalacqua is not associated to OpenCFD Ltd.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Customizing colors in the WSL terminal The default colors in the Ubuntu WSL terminal are not very readable. In particular, the blue color does not read well on the black background. While it is possible to customize colors in bash, a simpler workaround is to change colors using the Windows settings. To do this, click on the Ubuntu logo in the top-left corner of the WSL terminal window, and select Properties. This will open a dialog box with the specific settings to customize the launcher of the Ubuntu WSL terminal: Choose the &#8220;Colors&#8221; tab, and set: Screen text: Black Screen background: White Popup background: leave unchanged (purple) Popup background: White This will make the terminal more readable, at least according to my preferences. Editing code from Windows and compile it in WSL Editing files in WSL from both Windows and Linux is possible if the files are stored on the Windows file system. However, some care must be taken to avoid troubles. Before proceeding, please read this blog post, which clarifies the important points. More technical details are available here. The easy way to edit code in Windows, and use it in WSL is to store the code in a directory on Windows. Any directory in Windows drives (C:\\ etc) is fine. These drives are automatically mounted in WSL, and accessible at the path\u00a0\/mnt\/&lt;drive_letter&gt;\/. For example, the C:\\ drive is accessible to the Linux system running in WSL at the path \/mnt\/c\/ One simple approach is to create a folder in C:\\, which, in my case, I called SharedWSL, as shown below. The directory is accessible in the WSL terminal at \/mnt\/c\/SharedWSL and it is writable by both operating systems. It is convenient to create a shortcut on the Windows desktop to easily access this directory from the Windows environment. To achieve this, right click on the SharedWSL folder, and select &#8220;Create shortcut&#8221;. Windows will inform you that it cannot create one in C:\\, and offer the option to create it on your desktop. Accept to complete the operation. Setting up your Windows text editor to save files properly in the WSL operating system It is recommended to use a text editor which can save files with UNIX end of line. Most of the text editors let the user select this option. Here settings for Notepad++ are shown. Notepad++ offers two ways to select the UNIX (LF) option: Global setting in the Settings -&gt; Preferences&#8230; menu, under the &#8220;New document&#8221; tab: On a per-file basis, at the bottom of the notification area of the editor, boxed in red in the figure Enjoy\u00a0 This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM\u00ae and OpenCFD\u00ae trade marks. Alberto Passalacqua is not associated to OpenCFD Ltd.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-1650","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/www.albertopassalacqua.com\/index.php?rest_route=\/wp\/v2\/posts\/1650","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.albertopassalacqua.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.albertopassalacqua.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.albertopassalacqua.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.albertopassalacqua.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1650"}],"version-history":[{"count":8,"href":"https:\/\/www.albertopassalacqua.com\/index.php?rest_route=\/wp\/v2\/posts\/1650\/revisions"}],"predecessor-version":[{"id":1675,"href":"https:\/\/www.albertopassalacqua.com\/index.php?rest_route=\/wp\/v2\/posts\/1650\/revisions\/1675"}],"wp:attachment":[{"href":"https:\/\/www.albertopassalacqua.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.albertopassalacqua.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.albertopassalacqua.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}