<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Agrim Prasad</title>
    <description>The latest articles on DEV Community by Agrim Prasad (@agrim).</description>
    <link>https://dev.to/agrim</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F65993%2Fee68e06f-c804-4fd4-848f-4c594e62a6a4.jpeg</url>
      <title>DEV Community: Agrim Prasad</title>
      <link>https://dev.to/agrim</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/agrim"/>
    <language>en</language>
    <item>
      <title>Supercharge your Kubernetes setup with OhMyZSH 🚀🚀🚀 + awesome command-line tools</title>
      <dc:creator>Agrim Prasad</dc:creator>
      <pubDate>Fri, 03 Jan 2020 00:00:00 +0000</pubDate>
      <link>https://dev.to/agrim/supercharge-your-kubernetes-setup-with-ohmyzsh-awesome-command-line-tools-27om</link>
      <guid>https://dev.to/agrim/supercharge-your-kubernetes-setup-with-ohmyzsh-awesome-command-line-tools-27om</guid>
      <description>&lt;p&gt;Follow me on &lt;a href="https://twitter.com/AgrimPrasad"&gt;Twitter&lt;/a&gt;. Feel free to suggest ideas, give feedback or discuss any Backend or DevOps topics with me.&lt;/p&gt;

&lt;p&gt;Almost all of my colleagues who have worked with kubernetes have had similar complaints about the kubectl tool. It's so verbose! I need to remember such long commands! This lead me to search and discover a bunch of powerful cli tools, which combined with the OhMyZSH command-line framework can make your kubectl journey much smoother.&lt;/p&gt;

&lt;h2&gt;
  
  
  How you would usually use kubectl
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;kubectl&lt;/code&gt; by itself is a very powerful kubernetes client, and can be used for all kinds of purposes, but it really is too verbose, with a lot of gotchas in different commands.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Query the kubernetes pods running in specific namespaces of your kubernetes cluster.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get pod -n myZoo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Get the status of and details about different kubernetes entities, such as pods, configmaps, services etc.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl describe deployment myCatDeploy -n myZoo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Tail the logs of a specific container. Firstly, find the list of all pods with
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get pod -n myZoo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;then find your specific pod and run &lt;code&gt;kubectl logs&lt;/code&gt; (and hope you didn't make a typo anywhere)&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl logs -f myKittenPod -n myZoo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Tools to turbocharge kubectl
&lt;/h2&gt;

&lt;p&gt;We can do better.&lt;/p&gt;

&lt;p&gt;I give the installation instructions for these tools with macOS here. You can check the links to get installation instructions for other operating systems.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. kubectx to switch cluster &amp;amp; namespaces quickly
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/ahmetb/kubectx"&gt;kubectx&lt;/a&gt; can be installed on macOS with homebrew&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install kubectx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;This command actually installs two tools, &lt;code&gt;kubectx&lt;/code&gt; and &lt;code&gt;kubens&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can use &lt;code&gt;kubectx&lt;/code&gt; to switch between different clusters with &lt;code&gt;kubectx my-cluster-name&lt;/code&gt;. Behind the scenes, this command will edit your &lt;code&gt;~/.kube/config&lt;/code&gt; file to mark a specific cluster as being the &lt;code&gt;current-context&lt;/code&gt;. You would otherwise have to edit this file manually or use &lt;code&gt;kubectl config use-context my-cluster-name&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--i84JBa1X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/urp1gk4c3c0sr7kc9qvk.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i84JBa1X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/urp1gk4c3c0sr7kc9qvk.gif" alt="kubectx demo to switch between clusters"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubens&lt;/code&gt; helps you switch between namespaces quickly. Whereas earlier you would have had to run &lt;code&gt;kubectl config set-context --current --namespace=myZoo&lt;/code&gt;, now you can just run &lt;code&gt;kubens myZoo&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YOHT7yYM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zlfd6k5fomxx659i0toc.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YOHT7yYM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zlfd6k5fomxx659i0toc.gif" alt="kubens demo to switch between namespaces"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a bonus, I alias these tools to even shorter commands in my ZSH configuration file (&lt;code&gt;~/.zshrc&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias kctx="kubectx"
alias kns="kubens"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Then source the ZSH configuration file to load the changes.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Furthermore, if you use it with &lt;a href="https://github.com/ohmyzsh/ohmyzsh"&gt;OhMyZsh&lt;/a&gt; you can get auto-completion of namespaces and cluster names with these completion scripts. No need to remember those long namespaces anymore!&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir -p ~/.oh-my-zsh/completions
chmod -R 755 ~/.oh-my-zsh/completions
ln -s /opt/kubectx/completion/kubectx.zsh ~/.oh-my-zsh/completions/_kubectx.zsh
ln -s /opt/kubectx/completion/kubens.zsh ~/.oh-my-zsh/completions/_kubens.zsh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  2. kube-ps1 to display current cluster &amp;amp; namespace
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/jonmosco/kube-ps1"&gt;kube-ps1&lt;/a&gt; is a great companion tool to &lt;code&gt;kubectx&lt;/code&gt; and &lt;code&gt;kubens&lt;/code&gt; which displays the currently active cluster and namespace on your command line prompt. No more accidental deploys to the production cluster at 2AM.&lt;/p&gt;

&lt;p&gt;Install with:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install kube-ps1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Here's how your kubernetes cluster-name (&lt;code&gt;minikube&lt;/code&gt;) and namespace (&lt;code&gt;default&lt;/code&gt;) appear in the command prompt now:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--w1S5ZSMa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/yv0lkzkw92b916phb3jd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--w1S5ZSMa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/yv0lkzkw92b916phb3jd.png" alt="kube-ps1 screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's how it looks when combined with the &lt;code&gt;kubectx&lt;/code&gt; and &lt;code&gt;kubens&lt;/code&gt; tools to switch clusters and namespaces.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LT1YOux9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/qugs5gek6b0azc4ndz36.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LT1YOux9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/qugs5gek6b0azc4ndz36.gif" alt="kube-ps1 demo"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  3. OhMyZSH kubectl plugin for kubectl shortcuts
&lt;/h3&gt;

&lt;p&gt;OhMyZSH actually has a &lt;a href="https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/kubectl"&gt;plugin for kubectl&lt;/a&gt; which gives you nearly hundred shortcuts for commonly used commands. To use it, add &lt;code&gt;kubectl&lt;/code&gt; to the plugins array in your &lt;code&gt;~/.zshrc&lt;/code&gt; file and then source the &lt;code&gt;~/.zshrc&lt;/code&gt; file like before:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plugins=(... kubectl)
source ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Some shortcuts for commonly used commands provided by this plugin below.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Alias&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;k&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The kubectl command&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;kaf&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl apply -f&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Apply a YML file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;keti&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl exec -ti&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Drop into an interactive terminal on a container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;kdel&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl delete&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Delete resources by filenames, stdin, resources and names, or by resources and label selector&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;kgp&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;List all pods in ps output format&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;kdp&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl describe pods&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Describe all pods&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;kdelp&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl delete pods&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Delete all pods matching passed arguments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;kgd&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get deployment&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Get the deployment&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;… and more! Check out the full list on the &lt;a href="https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/kubectl/README.md"&gt;github page&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  4. stern for logs
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/wercker/stern"&gt;stern&lt;/a&gt; has been designed to allow you to tail the logs of multiple pods and containers using regex. This means that you can search pods by partial name matches, rather than having to query the full names of pods and then running &lt;code&gt;kubectl logs -f&lt;/code&gt; with the exact name of every single pod.&lt;/p&gt;

&lt;p&gt;Install with:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install stern
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;To receive and then tail all the available logs of all pods whose names partially match &lt;code&gt;myKitten&lt;/code&gt; (assuming &lt;code&gt;default&lt;/code&gt; namespace of the &lt;code&gt;minikube&lt;/code&gt; cluster used with &lt;code&gt;kubectx&lt;/code&gt;, &lt;code&gt;kubens&lt;/code&gt; and &lt;code&gt;kube-ps1&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(⎈ |minikube:default)➜ ~ stern myKitten
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;To receive the last 10 lines per container and then tail:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(⎈ |minikube:default)➜ ~ stern myKittenPod --tail=10
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;To receive the last 2 minutes of logs per container and then tail:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(⎈ |minikube:default)➜ ~ stern myKittenPod --since=2m
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;You can also source stern autocompletion with zsh by adding this to your &lt;code&gt;~/.zshrc&lt;/code&gt; and then running &lt;code&gt;source ~/.zshrc&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source &amp;lt;(stern --completion=zsh)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  5. kpoof to port-forward pods intuitively
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/farmotive/kpoof"&gt;kpoof&lt;/a&gt; is the easiest way to port-forward ports, which is often useful when you want to test an internal service which is not supposed to be publicly exposed outside the cluster.&lt;/p&gt;

&lt;p&gt;Install with:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew tap farmotive/k8s
brew install kpoof
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;With &lt;code&gt;kpoof&lt;/code&gt;, you get an interactive way to firstly choose the namespace, and then the name of the pod which you would like to port-forward. The tool forwards the same local port number as the port exposed by the pod by default.&lt;/p&gt;

&lt;p&gt;For example, in order to port-forward localhost port 3306 to port 3306 of the pod &lt;code&gt;nyc&lt;/code&gt; below, you can run the following commands:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kpoof
Namespace? (default zoo):
1 zoo
2 town
3 city
3
Pod number? (default 1):
1 nyc
2 london
3 bangkok
1
Forwarding from 127.0.0.1:3306 -&amp;gt; 3306
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;See it in action below.&lt;/p&gt;


&lt;div class="ltag_asciinema"&gt;
  
&lt;/div&gt;



&lt;h3&gt;
  
  
  6. Popeye to scan your cluster for potential issues
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/derailed/popeye"&gt;Popeye&lt;/a&gt; is a tool which scans your cluster for misconfigured resources. Currently, nodes, namespaces, pods and services are supported for scanning.&lt;/p&gt;

&lt;p&gt;When your cluster grows to 100s of different pods and to 10s of different namespaces, having such a tool is invaluable in detecting issues before they blow up, especially if you don't have monitoring on some of these resources.&lt;/p&gt;

&lt;p&gt;Install with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install derailed/popeye/popeye
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Run with the command &lt;code&gt;popeye&lt;/code&gt; to eye your entire cluster. Here's a screenshot of a well-maintained cluster which gets the cluster score &lt;code&gt;93 -- A&lt;/code&gt; from &lt;code&gt;popeye&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hUGhIRHF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/cu978wc7x47plf92di1m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hUGhIRHF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/cu978wc7x47plf92di1m.png" alt="popeye screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Know of any other useful CLI or GUI utilities for kubernetes? Let me know in the comments below!&lt;/p&gt;

</description>
      <category>tips</category>
      <category>kubernetes</category>
      <category>devops</category>
      <category>docker</category>
    </item>
    <item>
      <title>How to Open Link in New Tab with Hugo's new Goldmark Markdown Renderer</title>
      <dc:creator>Agrim Prasad</dc:creator>
      <pubDate>Sun, 29 Dec 2019 00:00:00 +0000</pubDate>
      <link>https://dev.to/agrim/how-to-open-link-in-new-tab-with-hugo-s-new-goldmark-markdown-renderer-2bcn</link>
      <guid>https://dev.to/agrim/how-to-open-link-in-new-tab-with-hugo-s-new-goldmark-markdown-renderer-2bcn</guid>
      <description>&lt;p&gt;This post was originally published on my blog, find original post &lt;a href="https://agrimprasad.com/post/hugo-goldmark-markdown/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gohugo.io/"&gt;Hugo&lt;/a&gt; is a blazing fast static site generator, which makes it a terrific choice to create your blogs. It's written in Go and uses Go's templating language to generate blog content with customizable templates for styling.&lt;/p&gt;

&lt;p&gt;Check out &lt;a href="https://dev.to/effingkay/build-your-own-blog-with-hugo-and-netlify-oi7"&gt;this article&lt;/a&gt; for a good overview of Hugo, and how to get your blog online with Hugo + Netlify.&lt;/p&gt;

&lt;p&gt;Furthermore, Hugo uses Markdown to render your content, which is similar to the rendering mechanisms used by other blogging engines, such as &lt;a href="https://jekyllrb.com/"&gt;Jekyll&lt;/a&gt; (used by &lt;a href="https://pages.github.com/"&gt;Github Pages&lt;/a&gt;) and &lt;a href="//dev.to"&gt;DEV.TO&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to open links in a new tab with markdown in Hugo?
&lt;/h2&gt;

&lt;p&gt;When creating my blog in Hugo, I wanted to open links in a new tab (i.e. add a &lt;code&gt;target="_blank"&lt;/code&gt; attribute to the links). However, by default, an inline style link in Markdown opens in the same tab, which means that your reader may leave your blog and go to a different site, never to return.&lt;/p&gt;

&lt;p&gt;Until recent versions of Hugo, it had been using the &lt;code&gt;Blackfriday&lt;/code&gt; Markdown renderer, which while convenient, is not &lt;a href="https://spec.commonmark.org/0.29/"&gt;CommonMark&lt;/a&gt; standards-compliant. With &lt;code&gt;Blackfriday&lt;/code&gt;, I could achieve my desired behaviour by adding the following configuration to the &lt;code&gt;config.toml&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[blackfriday]
hrefTargetBlank = true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;However, in the latest Hugo v0.62.0, this doesn't work anymore as the default markdown renderer has changed to &lt;a href="https://github.com/yuin/goldmark"&gt;Goldmark&lt;/a&gt;, which is CommonMark compliant and allows for custom templates to render links and images from markdown. Thus, if you want to open your blog's links in a new tab (which is not supported by default), you'll have to use a custom markdown render hook to add the &lt;code&gt;target="_blank"&lt;/code&gt; attribute to the links.&lt;/p&gt;

&lt;h2&gt;
  
  
  Render Hooks with Goldmark
&lt;/h2&gt;

&lt;p&gt;Goldmark and &lt;a href="https://gohugo.io/getting-started/configuration-markup/#markdown-render-hooks"&gt;Markdown Render Hooks&lt;/a&gt; are a new feature in Hugo v0.62.0 so please make sure that your Hugo version is equal to or greater than this version.&lt;/p&gt;

&lt;p&gt;Markdown Render Hooks offer you several ways to extend the default markdown behaviour, e.g. resizing of uploaded images, or opening links in new tabs. You can do this by creating templates in the &lt;code&gt;layouts/_default/_markup&lt;/code&gt; directory with base names &lt;code&gt;render-link&lt;/code&gt; or &lt;code&gt;render-image&lt;/code&gt;. Your directory layout may look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;layouts
└── _default
└── _markup
├── render-image.html
├── render-image.rss.xml
└── render-link.html
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Sample render hook to open link in new tab
&lt;/h3&gt;

&lt;p&gt;Say you have an inline-style link in Markdown such as the follows with the &lt;code&gt;Destination&lt;/code&gt; as &lt;code&gt;https://en.wikipedia.org/wiki/Pizza&lt;/code&gt;, &lt;code&gt;Text&lt;/code&gt; as &lt;code&gt;Pizza&lt;/code&gt; and &lt;code&gt;Title&lt;/code&gt; as &lt;code&gt;Yum Yum&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Pizza](https://en.wikipedia.org/wiki/Pizza "Yum Yum")
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;By default, this link would open in the same tab.&lt;/p&gt;

&lt;p&gt;Now add the following HTML template file (or render hook) at &lt;code&gt;layouts/_default/_markup/render-link.html&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank"{{ end }}&amp;gt;{{ .Text }}&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You'll find that the previous link now opens in a new tab!&lt;/p&gt;

&lt;p&gt;For internal blog links (which you would want to open in the same tab), you can use the relative link of the post, e.g. for a &lt;code&gt;sample-post.md&lt;/code&gt; file within the &lt;code&gt;posts&lt;/code&gt; directory, you could use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Sample post](/posts/sample-post/)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;The Markdown renderer has changed in the latest Hugo v0.62.0 from &lt;code&gt;Blackfriday&lt;/code&gt; to &lt;code&gt;Goldmark&lt;/code&gt; which should allow Hugo markdown to be more compatible with other markdown flavours, such as that of GitHub.&lt;/li&gt;
&lt;li&gt;In order to open links in new tab with the &lt;code&gt;Goldmark&lt;/code&gt; markdown renderer, create a file at &lt;code&gt;layouts/_default/_markup/render-link.html&lt;/code&gt; with the following content:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank"{{ end }}&amp;gt;{{ .Text }}&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>tips</category>
      <category>hugo</category>
      <category>markdown</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Freelancers and digital agency owners, what do you use to deploy client websites?</title>
      <dc:creator>Agrim Prasad</dc:creator>
      <pubDate>Sun, 08 Jul 2018 03:21:18 +0000</pubDate>
      <link>https://dev.to/agrim/freelancers-and-digital-agency-owners-what-do-you-use-to-deploy-client-websites-14mc</link>
      <guid>https://dev.to/agrim/freelancers-and-digital-agency-owners-what-do-you-use-to-deploy-client-websites-14mc</guid>
      <description>&lt;p&gt;I've noticed that most ecommerce online stores are hosted on Shopify nowadays, as I noticed from this post:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/samjarman" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F19747%2F97b2fe78-0de2-4c81-91aa-a41493c58b60.png" alt="samjarman"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/samjarman/starting-an-agency-with-kelly-vaughn-5699" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Starting An Agency with Kelly Vaughn&lt;/h2&gt;
      &lt;h3&gt;Sam Jarman 👨🏼‍💻 ・ Jul 7 '18&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#agency&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#businessowner&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#career&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;How about other kinds of websites created by the freelancers and digital agency owners of this community? Do you host on shared hosts? Or VPS providers such as Digital Ocean? Or Cloud services such as AWS? &lt;/p&gt;

&lt;p&gt;The most challenging part (for me) about VPS providers and cloud services is the management of your servers across different services, once the number of your servers goes past 4 or 5.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>webdev</category>
      <category>agency</category>
    </item>
    <item>
      <title>Monitor the performance of any command line program with this single command</title>
      <dc:creator>Agrim Prasad</dc:creator>
      <pubDate>Sat, 07 Jul 2018 08:32:54 +0000</pubDate>
      <link>https://dev.to/agrim/monitor-the-performance-of-any-command-line-program-with-this-single-command-46je</link>
      <guid>https://dev.to/agrim/monitor-the-performance-of-any-command-line-program-with-this-single-command-46je</guid>
      <description>&lt;p&gt;This post was originally published on my blog, find original post &lt;a href="https://agrimprasad.com/post/monitor-the-performance-of-any-command-line-program-with-this-single-command/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I have been executing a lot of bash scripts and one-off processes on the linux command line recently, and was curious about how to monitor the CPU and memory usage of these processes as quickly as possible. Some of these processes seemed to bring my linux box to a screeching halt, and without instant resource monitoring I couldn't tell whether such a process was eating excessive RAM or CPU (or both?!)&lt;/p&gt;

&lt;h2&gt;
  
  
  What people usually do
&lt;/h2&gt;

&lt;p&gt;Conventionally, &lt;a href="https://unix.stackexchange.com/questions/554/how-to-monitor-cpu-memory-usage-of-a-single-process" rel="noopener noreferrer"&gt;suggestions about process monitoring&lt;/a&gt; involve the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Run your command line process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get the PID of the process with &lt;a href="https://unix.stackexchange.com/questions/106847/what-does-aux-mean-in-ps-aux" rel="noopener noreferrer"&gt;&lt;code&gt;ps aux&lt;/code&gt;&lt;/a&gt; command which is generally available for both Linux and Mac.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the utility &lt;a href="http://man7.org/linux/man-pages/man1/top.1.html" rel="noopener noreferrer"&gt;&lt;code&gt;top&lt;/code&gt;&lt;/a&gt; with &lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;top -p &amp;lt;pid&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;on Linux or &lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;top -pid &amp;lt;pid&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;on Mac OS.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;However, I wanted to run commands which would exit within a few seconds, before I could run &lt;code&gt;top&lt;/code&gt; to start monitoring them. How could I start monitoring these commands as soon as they were invoked?&lt;/p&gt;

&lt;h2&gt;
  
  
  What can we do better
&lt;/h2&gt;

&lt;p&gt;As always, Unix has an answer:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Run your command in the background and pipe the output to &lt;code&gt;/dev/null&lt;/code&gt; so that it doesn't get printed on the command line while you are monitoring the CPU/memory usage, e.g. &lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;unzip ~/Downloads/sample.zip &amp;gt; /dev/null &amp;amp;
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Echo the PID of this background process with &lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo $!
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Combine the two, and pass the pid of the process to &lt;code&gt;top&lt;/code&gt; with &lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;top -p `{ unzip ~/Downloads/sample.zip &amp;gt; /dev/null &amp;amp; } &amp;amp;&amp;amp; echo $!`
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;on linux or&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;top -pid `{ unzip ~/Downloads/sample.zip &amp;gt; /dev/null &amp;amp; } &amp;amp;&amp;amp; echo $!`
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;on Mac OS.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;BOOM, you just started monitoring your process immediately with a single command. Now isn't that peachy!&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: Use &lt;code&gt;htop&lt;/code&gt; instead of &lt;code&gt;top&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;I ❤️ &lt;a href="https://github.com/hishamhm/htop" rel="noopener noreferrer"&gt;htop&lt;/a&gt; which is a process monitoring utility available for both linux and Mac OS. Come on, you've got colours! Let's use this instead of &lt;code&gt;top&lt;/code&gt; for better insight into the CPU/memory performance of our processes.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install &lt;code&gt;htop&lt;/code&gt; with &lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install htop
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;on Ubuntu or &lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install htop
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;on Mac OS with &lt;a href="https://brew.sh/" rel="noopener noreferrer"&gt;Homebrew&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run our previous monitoring command using &lt;code&gt;htop&lt;/code&gt; instead of &lt;code&gt;top&lt;/code&gt; for monitoring with &lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;htop -p `{ unzip ~/Downloads/sample.zip &amp;gt; /dev/null &amp;amp; } &amp;amp;&amp;amp; echo $!`
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;See the single command in action below!&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FFepzxVp.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FFepzxVp.gif" alt="Single command process monitoring with htop"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Double Bonus: Style your editor for a more beautiful htop
&lt;/h2&gt;

&lt;p&gt;Saw some chatter on Twitter about this post which mentioned that I should have added information about the terminal theme I'm using here, since htop gets styled by the terminal and theme in use. I totally agree, so here's my setup:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Terminal emulator: &lt;a href="https://www.iterm2.com/" rel="noopener noreferrer"&gt;iTerm2&lt;/a&gt; Awesome Mac OS Terminal replacement with cool features such as grid tabs and more.&lt;/li&gt;
&lt;li&gt;Unix shell + theming framework: &lt;code&gt;zsh&lt;/code&gt; + &lt;a href="https://github.com/robbyrussell/oh-my-zsh" rel="noopener noreferrer"&gt;oh-my-zsh&lt;/a&gt; Check out &lt;a href="https://dev.to/lauragift21/quick-setup-of-oh-my-zsh-terminal-on-ubuntu-2c4e"&gt;this awesome post&lt;/a&gt; about how to install these (similar steps on Ubuntu or Mac OS)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;oh-my-zsh&lt;/code&gt; theme: Default theme &lt;code&gt;robbyrussell&lt;/code&gt;. After setting up &lt;code&gt;oh-my-zsh&lt;/code&gt;, you can specify the desired theme in the &lt;code&gt;~/.zshrc&lt;/code&gt; file, e.g. &lt;code&gt;ZSH_THEME="robbyrussell"&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>tips</category>
      <category>linux</category>
      <category>macos</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
