{"id":683,"date":"2018-09-17T10:00:48","date_gmt":"2018-09-17T08:00:48","guid":{"rendered":"https:\/\/craftcoders.app\/?p=683"},"modified":"2024-08-14T14:27:54","modified_gmt":"2024-08-14T12:27:54","slug":"5-things-i-love-about-wsl","status":"publish","type":"post","link":"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/","title":{"rendered":"5 Things I love about WSL"},"content":{"rendered":"\r\n

I got a new PC and love it! But a new PC also means a whole new setup and a lot of work. One of the first things I\u2019ve setup has been the Windows Subsystem for Linux. I know I am a developer and most of you would not expect me to work on a windows machine. Guys I must tell you windows is fucking awesome and with WSL it\u2019s just getting more awesome! Here five things I really love about WSL<\/p>\r\n\r\n\r\n\r\n

1. Interoperability
<\/span><\/h2>\r\n\r\n\r\n\r\n

Starting with Windows build 14951 Microsoft added the possibility to (1) invoke Linux binaries from the Windows Console (2) invoke Windows binaries from the Linux Console and (3) sharing environment variables between Windows and Linux. Furthermore, with the Fall creates Update Microsoft include the windows path in the Linux $Path so it is easy to call windows binaries from Linux. So, to call Windows binaries from windows you just must type:<\/p>\r\n\r\n\r\n\r\n

[binaries name].exe<\/pre>\r\n\r\n\r\n\r\n

For instance, you could open the windows file explorer at the current location of your windows console by simply calling:<\/p>\r\n\r\n\r\n\r\n

 explorer.exe .<\/pre>\r\n\r\n\r\n\r\n
\"\"\r\n
launching explorer from the Linux Console<\/figcaption>\r\n<\/figure>\r\n\r\n\r\n\r\n

2. Docker<\/h2>\r\n\r\n\r\n\r\n

Okay now I gonna cheat but its so cool it deserves to be its own point. Due to the Interoperability between WSL and Windows you do not need to expose some creepy port or build complicated relay <\/a>between WSL and Windows. You can just run \u201cdocker.exe\u201d to use docker for windows inside your Linux console. Ok I admit this is not very practical since you have always to type \u201c.exe\u201d. But Linux is awesome and lets you define aliases so such things. All you need to do is:<\/p>\r\n\r\n\r\n\r\n

    \r\n
  1. Open ~\/.bashrc<\/em><\/li>\r\n
  2. Go to the end of the file<\/li>\r\n
  3. Add following lines (at the end)
    alias docker=docker.exe<\/em>
    alias docker-compose=docker-compose.exe<\/em><\/li>\r\n<\/ol>\r\n\r\n\r\n\r\n
    \"\"\r\n
    Docker<\/figcaption>\r\n<\/figure>\r\n\r\n\r\n\r\n

    3. WSLGIT<\/h2>\r\n\r\n\r\n\r\n

    As mentioned in (1) you can execute windows binaries from the Linux console. As a result, you can open VSCode from the Linux Console. Here\u00b4s the catch: VSCode would still use Git for Windows. This is not really a problem and works. I really love to use git inside my Linux console, but I don\u2019t want to manage two git installations on the same machine. One could argue that you could do the same trick as we did with docker and that\u2019s true but this time we do is the other way round. There is a GitHub Project from andy-5 that is called WSLGIT<\/a>. Basically, this project aims to provide a small executable that forwards arguments to git running inside Bash on Windows. All that needs to be done is:<\/p>\r\n\r\n\r\n\r\n

      \r\n
    1. Download <\/a>the executable<\/li>\r\n
    2. Save the .exe somewhere<\/li>\r\n
    3. Change the settings of your IDEs to use wslgit.exe<\/em> as git executable<\/li>\r\n<\/ol>\r\n\r\n\r\n\r\n

      4. X-Server for Windows<\/h2>\r\n\r\n\r\n\r\n

      So, what can\u2019t be done with WSL? Right you can not run graphical applications. Can`t you? That\u2019s just partial true: You can use an implementation of X-Server for windows and forward it inside your bash. I use the Xming X Server<\/a>. Simply download it and install it. After installation open XLaunch, select \u201cMultiple Windows\u201d and \u201cDisplay Number 0\u201d at the first screen. Select \u201cStart no client\u201d at the second screen. Select \u201cClipboard\u201d and go forward. Now you can save this configuration and add it to your autostart folder. That why you never have to configure it again (even when we just used the default configuration ?). Inside your Linux console you just must run<\/p>\r\n\r\n\r\n\r\n

      export DISPLAY=:0<\/pre>\r\n\r\n\r\n\r\n

      and you are ready to go. Now you can start graphical applications!<\/p>\r\n\r\n\r\n\r\n

      Fixing HDPI<\/h3>\r\n\r\n\r\n\r\n

      You may encounter the same problem as I did. My new PC got a UHD resolution and graphical applications running with Xming X Server are blurry. This is the fault of the windows compatibility mode that is scaling the application. To fix it you need:

      1. Navigate to the installation folder of Xming\u00a0
      2. Open the Properties<\/strong> of Xming.exe
      3. Click on compatibility
      <\/strong>4. Click on HDPI-Settings
      <\/strong>5. Override HDPI-Setting with application defaults<\/p>\r\n\r\n\r\n\r\n

      \"\"\r\n
      DPI-Settings<\/figcaption>\r\n<\/figure>\r\n\r\n\r\n\r\n



      So, every Linux application is really small ?. But don\u2019t mind we can fix that inside Linux! If we use GTK application, we can just increase the GTK scaling factor by typing:

      export GDK_SCALE=3<\/em> <\/p>\r\n\r\n\r\n\r\n

      \"\"\r\n
      The power of X-Server<\/figcaption>\r\n<\/figure>\r\n\r\n\r\n\r\n

      5. Seamlessly using Linux<\/h2>\r\n\r\n\r\n\r\n

      This sums it up, but I will show you what I mean by example. We gonna run Tilix<\/a>, a tiling terminal emulator for Linux using GTK+ 3, as it would be a ordinary windows application. Note to do that, you need to follow the instructions under point (4). I\u2019m assuming you already did that.<\/strong> To install Tilix we just need to type<\/p>\r\n\r\n\r\n\r\n

      sudo add-apt-repository ppa:webupd8team\/terminix<\/pre>\r\n\r\n\r\n\r\n
      sudo apt-get update<\/pre>\r\n\r\n\r\n\r\n
      sudo apt-get install tilix<\/pre>\r\n\r\n\r\n\r\n

      You might encounter some problems regarding the dbus service. For instance you could get a error message like this:<\/p>\r\n\r\n\r\n\r\n

      failed to commit changes to dconf: Failed to execute child process \u201cdbus-launch\u201d (No such file or directory)<\/em><\/p>\r\n\r\n\r\n\r\n

       <\/p>\r\n\r\n\r\n\r\n

      Dont you worry child! It is easy to fix. We just need to install the dbus-service and run execute it:<\/p>\r\n\r\n\r\n\r\n

      sudo apt-get install dbus-x11<\/pre>\r\n\r\n\r\n\r\n
      sudo service dbus start<\/pre>\r\n\r\n\r\n\r\n

      That\u2019s all! The make it more convenient to use we are going to write a small script to launch it. Just open VSCode and copy and paste following:<\/p>\r\n\r\n\r\n\r\n

      args = \"-c\" & \" -l \" & \"\"\"GDK_SCALE=3 DISPLAY=:0 tilix\"\"\"\r\n\r\nWScript.CreateObject(\"Shell.Application\").ShellExecute \"bash\", args, \"\", \"open\", 0<\/code><\/pre>\r\n\r\n\r\n\r\n

      NOTE: if you don\u2019t have UDH resolution you can remove following GDK_SCALE=3.<\/strong>\u00a0Save the script under …Programms\/Tilix<\/em> and name it tilix.vbs<\/strong>. Now we need a second script a simple bat file that we use to invoke our first script:<\/p>\r\n\r\n\r\n\r\n

      WScript tilix.vbs<\/code><\/pre>\r\n\r\n\r\n\r\n

      Almost done! We can now send the bat script to the deskop and get a nice clickable icon that can be used to launch Tilix. If you put it in the Startmenu folder you can even use it from the Startmenu in windows 10!<\/p>\r\n\r\n\r\n\r\n

      \"\"\r\n
      running tilix<\/figcaption>\r\n<\/figure>\r\n","protected":false},"excerpt":{"rendered":"

      I got a new PC and love it! But a new PC also means a whole new setup and a lot of work. One of the first things I\u2019ve setup has been the Windows Subsystem for Linux. I know I am a developer and most of you would not expect me to work on a windows machine. Guys I must … Read More<\/a><\/p>\n","protected":false},"author":8,"featured_media":2334,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[109,143],"tags":[],"acf":[],"yoast_head":"\n5 Things I love about WSL - CraftCoders.app<\/title>\n<meta name=\"description\" content=\"5 easy to apply tricks that pimps your experience with WSL. Learn how you can use docker and graphical applications from your linux console. Fix HDPI\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"5 Things I love about WSL - CraftCoders.app\" \/>\n<meta property=\"og:description\" content=\"5 easy to apply tricks that pimps your experience with WSL. Learn how you can use docker and graphical applications from your linux console. Fix HDPI\" \/>\n<meta property=\"og:url\" content=\"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/\" \/>\n<meta property=\"og:site_name\" content=\"CraftCoders.app\" \/>\n<meta property=\"article:published_time\" content=\"2018-09-17T08:00:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-14T12:27:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/craftcoders.app\/wp-content\/uploads\/2018\/09\/paste-768x635-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"768\" \/>\n\t<meta property=\"og:image:height\" content=\"635\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Cem Freimoser\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Cem Freimoser\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/\",\"url\":\"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/\",\"name\":\"5 Things I love about WSL - CraftCoders.app\",\"isPartOf\":{\"@id\":\"https:\/\/craftcoders.app\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/craftcoders.app\/wp-content\/uploads\/2018\/09\/paste-768x635-1.jpg\",\"datePublished\":\"2018-09-17T08:00:48+00:00\",\"dateModified\":\"2024-08-14T12:27:54+00:00\",\"author\":{\"@id\":\"https:\/\/craftcoders.app\/#\/schema\/person\/1de3ca624627af12a8288c134309e6c4\"},\"description\":\"5 easy to apply tricks that pimps your experience with WSL. Learn how you can use docker and graphical applications from your linux console. Fix HDPI\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/#primaryimage\",\"url\":\"https:\/\/craftcoders.app\/wp-content\/uploads\/2018\/09\/paste-768x635-1.jpg\",\"contentUrl\":\"https:\/\/craftcoders.app\/wp-content\/uploads\/2018\/09\/paste-768x635-1.jpg\",\"width\":768,\"height\":635},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/craftcoders.app\/#website\",\"url\":\"https:\/\/craftcoders.app\/\",\"name\":\"CraftCoders.app\",\"description\":\"Jira and Confluence apps\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/craftcoders.app\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/craftcoders.app\/#\/schema\/person\/1de3ca624627af12a8288c134309e6c4\",\"name\":\"Cem Freimoser\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/craftcoders.app\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6fcc13f5b3fd0bb1d5c3801174819538?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6fcc13f5b3fd0bb1d5c3801174819538?s=96&d=mm&r=g\",\"caption\":\"Cem Freimoser\"},\"url\":\"https:\/\/craftcoders.app\/author\/cem\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"5 Things I love about WSL - CraftCoders.app","description":"5 easy to apply tricks that pimps your experience with WSL. Learn how you can use docker and graphical applications from your linux console. Fix HDPI","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/","og_locale":"en_US","og_type":"article","og_title":"5 Things I love about WSL - CraftCoders.app","og_description":"5 easy to apply tricks that pimps your experience with WSL. Learn how you can use docker and graphical applications from your linux console. Fix HDPI","og_url":"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/","og_site_name":"CraftCoders.app","article_published_time":"2018-09-17T08:00:48+00:00","article_modified_time":"2024-08-14T12:27:54+00:00","og_image":[{"width":768,"height":635,"url":"https:\/\/craftcoders.app\/wp-content\/uploads\/2018\/09\/paste-768x635-1.jpg","type":"image\/jpeg"}],"author":"Cem Freimoser","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Cem Freimoser","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/","url":"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/","name":"5 Things I love about WSL - CraftCoders.app","isPartOf":{"@id":"https:\/\/craftcoders.app\/#website"},"primaryImageOfPage":{"@id":"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/#primaryimage"},"image":{"@id":"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/#primaryimage"},"thumbnailUrl":"https:\/\/craftcoders.app\/wp-content\/uploads\/2018\/09\/paste-768x635-1.jpg","datePublished":"2018-09-17T08:00:48+00:00","dateModified":"2024-08-14T12:27:54+00:00","author":{"@id":"https:\/\/craftcoders.app\/#\/schema\/person\/1de3ca624627af12a8288c134309e6c4"},"description":"5 easy to apply tricks that pimps your experience with WSL. Learn how you can use docker and graphical applications from your linux console. Fix HDPI","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/craftcoders.app\/5-things-i-love-about-wsl\/#primaryimage","url":"https:\/\/craftcoders.app\/wp-content\/uploads\/2018\/09\/paste-768x635-1.jpg","contentUrl":"https:\/\/craftcoders.app\/wp-content\/uploads\/2018\/09\/paste-768x635-1.jpg","width":768,"height":635},{"@type":"WebSite","@id":"https:\/\/craftcoders.app\/#website","url":"https:\/\/craftcoders.app\/","name":"CraftCoders.app","description":"Jira and Confluence apps","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/craftcoders.app\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/craftcoders.app\/#\/schema\/person\/1de3ca624627af12a8288c134309e6c4","name":"Cem Freimoser","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/craftcoders.app\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6fcc13f5b3fd0bb1d5c3801174819538?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6fcc13f5b3fd0bb1d5c3801174819538?s=96&d=mm&r=g","caption":"Cem Freimoser"},"url":"https:\/\/craftcoders.app\/author\/cem\/"}]}},"_links":{"self":[{"href":"https:\/\/craftcoders.app\/wp-json\/wp\/v2\/posts\/683"}],"collection":[{"href":"https:\/\/craftcoders.app\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/craftcoders.app\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/craftcoders.app\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/craftcoders.app\/wp-json\/wp\/v2\/comments?post=683"}],"version-history":[{"count":1,"href":"https:\/\/craftcoders.app\/wp-json\/wp\/v2\/posts\/683\/revisions"}],"predecessor-version":[{"id":2335,"href":"https:\/\/craftcoders.app\/wp-json\/wp\/v2\/posts\/683\/revisions\/2335"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/craftcoders.app\/wp-json\/wp\/v2\/media\/2334"}],"wp:attachment":[{"href":"https:\/\/craftcoders.app\/wp-json\/wp\/v2\/media?parent=683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/craftcoders.app\/wp-json\/wp\/v2\/categories?post=683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/craftcoders.app\/wp-json\/wp\/v2\/tags?post=683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}