<?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: Maroun Maroun</title>
    <description>The latest articles on DEV Community by Maroun Maroun (@marounmaroun).</description>
    <link>https://dev.to/marounmaroun</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%2F302800%2F6a1d78cc-287b-40ce-9107-5961b73b0e13.jpeg</url>
      <title>DEV Community: Maroun Maroun</title>
      <link>https://dev.to/marounmaroun</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/marounmaroun"/>
    <language>en</language>
    <item>
      <title>A Short Journey to Git Internals</title>
      <dc:creator>Maroun Maroun</dc:creator>
      <pubDate>Mon, 28 Sep 2020 14:24:23 +0000</pubDate>
      <link>https://dev.to/marounmaroun/a-short-journey-to-git-internals-4583</link>
      <guid>https://dev.to/marounmaroun/a-short-journey-to-git-internals-4583</guid>
      <description>&lt;p&gt;In this article, we’ll dive into Git internals by going through a real example. If you don’t have your terminal open already, do so, fasten your seatbelts, and let’s go! 💨&lt;/p&gt;

&lt;h3&gt;
  
  
  Initializing a Git repository
&lt;/h3&gt;

&lt;p&gt;You have probably already initialized an empty Git project using &lt;code&gt;git init&lt;/code&gt;, but did you ever wondered what does this command do?&lt;/p&gt;

&lt;p&gt;Let’s create an empty folder, and initialize an empty Git project. From the official &lt;a href="https://git-scm.com/docs/git-init"&gt;Git documentation&lt;/a&gt;, &lt;code&gt;git init&lt;/code&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This command creates an empty Git repository — basically a .git directory with subdirectories for &lt;code&gt;objects&lt;/code&gt;, &lt;code&gt;refs/heads&lt;/code&gt;, &lt;code&gt;refs/tags&lt;/code&gt;, and template files. An initial &lt;code&gt;HEAD&lt;/code&gt; file that references the &lt;code&gt;HEAD&lt;/code&gt; of the master branch is also created.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If we inspect the folder’s content, we’ll see the following structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;tree &lt;span class="nt"&gt;-L&lt;/span&gt; 1 .git/
.git/
├── HEAD
├── config
├── description
├── hooks
├── info
├── objects
└── refs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Git is a key-value datastore
&lt;/h3&gt;

&lt;p&gt;At its core, Git is a content-addressable filesystem. Huh? 🤔 Ok, Git is simply a key-value database. You insert any kind of content into a Git repository, for which Git will give you back a unique identifier (a key) that you can use to retrieve that content back.&lt;/p&gt;

&lt;p&gt;Git uses the &lt;a href="https://git-scm.com/docs/git-hash-object"&gt;hash-object&lt;/a&gt; command to store values into the database:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Computes the object ID value for an object with specified type with the contents of the named file (which can be outside of the work tree), and optionally writes the resulting object into the object database. Reports its object ID to its standard output. When  is not specified, it defaults to “blob”.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;“blob” is nothing but a sequence of bytes. A Git blob contains the exact data as a file, but it’s stored in the Git key-value data store, while the “actual” file is stored on the file system.&lt;/p&gt;

&lt;p&gt;Let’s create a blob:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo &lt;/span&gt;hello | git hash-object &lt;span class="nt"&gt;--stdin&lt;/span&gt; &lt;span class="nt"&gt;-w&lt;/span&gt;
ce013625030ba8dba906f756967f9e9ca394464a
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We used the &lt;code&gt;-w&lt;/code&gt; flag to actually write the object into the object database, and not only display it (achieved by the &lt;code&gt;--stdin&lt;/code&gt; flag).&lt;/p&gt;

&lt;p&gt;The value “hello” is the “value” in the Git data store, and the hash returned from the &lt;code&gt;hash-object&lt;/code&gt; function is in this case our key. We can now do the opposite operation to read the value by its key, using the &lt;a href="https://git-scm.com/docs/git-cat-file"&gt;&lt;code&gt;git-cat-file&lt;/code&gt;&lt;/a&gt; command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git cat-file &lt;span class="nt"&gt;-p&lt;/span&gt; ce013625030ba8dba906f756967f9e9ca394464a
hello
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We can check its type using the &lt;code&gt;-t&lt;/code&gt; flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git cat-file &lt;span class="nt"&gt;-t&lt;/span&gt; ce013625030ba8dba906f756967f9e9ca394464a
blob
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;git &lt;code&gt;hash-object&lt;/code&gt; stores the data in the &lt;code&gt;.git/objects/&lt;/code&gt; folder (AKA the object database). Let’s verify:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;tree .git/objects/
.git/objects/
├── ce
│   └── 013625030ba8dba906f756967f9e9ca394464a
├── info
└── pack
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The hash suffix (under the “ce” directory) is the same as the one we got back from the &lt;code&gt;hash-object&lt;/code&gt; function, but it has a different prefix. Why? That’s because the parent folder name contains the first two characters of our key. Why? Because some file systems have limitations on numbers of sub-directories. So introducing this layer mitigates that problem.&lt;/p&gt;

&lt;p&gt;Let’s save another object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo &lt;/span&gt;world | git hash-object &lt;span class="nt"&gt;--stdin&lt;/span&gt; &lt;span class="nt"&gt;-w&lt;/span&gt;
cc628ccd10742baea8241c5924df992b5c019f71
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As expected, we’ll now have two directories under &lt;code&gt;.git/objects/&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;tree .git/objects/
.git/objects/
├── cc
│   └── 628ccd10742baea8241c5924df992b5c019f71
├── ce
│   └── 013625030ba8dba906f756967f9e9ca394464a
├── info
└── pack
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and again, the &lt;code&gt;cc&lt;/code&gt; folder, which has the key’s prefix, has the rest of the key in the contained file’s name.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tree Objects 🌲
&lt;/h3&gt;

&lt;p&gt;The next Git object we’ll investigate is the tree. This type solves the problem of storing the filename and allows storing a group of files together.&lt;br&gt;
A tree object contains entries. Each entry is the SHA-1 of the blob, or subtree with its associated mode, type, and filename. Let’s check the &lt;a href="https://git-scm.com/docs/git-mktree"&gt;&lt;code&gt;git-mktree&lt;/code&gt;&lt;/a&gt; documentation:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Reads standard input in non-recursive &lt;code&gt;ls-tree&lt;/code&gt; output format, and creates a tree object. The order of the tree entries is normalized by mktree so pre-sorting the input is not required. The object name of the tree object built is written to the standard output.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you’re wondering about &lt;a href="https://git-scm.com/docs/git-ls-tree"&gt;&lt;code&gt;ls-tree&lt;/code&gt;&lt;/a&gt; output format, it looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;mode&amp;gt; SP &amp;lt;type&amp;gt; SP &amp;lt;object&amp;gt; TAB &amp;lt;file&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let’s now associate the two blobs above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'%s %s %s\t%s\n'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    100644 blob ce013625030ba8dba906f756967f9e9ca394464a hello.txt &lt;span class="se"&gt;\&lt;/span&gt;
    100644 blob cc628ccd10742baea8241c5924df992b5c019f71 world.txt |
  git mktree
88e38705fdbd3608cddbe904b67c731f3234c45b
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;mktree&lt;/code&gt; returns a key for the newly created tree object.&lt;/p&gt;

&lt;p&gt;At this point, we can visualize our tree as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             88e38705fdbd3608cddbe904b67c731f3234c45b  
                                |                   
                  +-------------|------------+             
                  |                          |        
                  |                          |        
                  |                          |          
                  |                          |       
                  |                          |
                hello                       world        
            ce013625030b                 cc628ccd1074
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let’s view the tree’s content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git cat-file &lt;span class="nt"&gt;-p&lt;/span&gt; 88e38705fdbd3608cddbe904b67c731f3234c45b
100644 blob ce013625030ba8dba906f756967f9e9ca394464a hello.txt
100644 blob cc628ccd10742baea8241c5924df992b5c019f71 world.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and of course, the &lt;code&gt;.git/objects&lt;/code&gt; was updated accordingly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;tree .git/objects/
.git/objects/
├── 88
│   └── e38705fdbd3608cddbe904b67c731f3234c45b
├── cc
│   └── 628ccd10742baea8241c5924df992b5c019f71
├── ce
│   └── 013625030ba8dba906f756967f9e9ca394464a
├── info
└── pack
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So far we &lt;strong&gt;have not&lt;/strong&gt; updated our index. To do so, we use the &lt;a href="https://git-scm.com/docs/git-read-tree"&gt;&lt;code&gt;git-read-tree&lt;/code&gt;&lt;/a&gt; command:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Reads the tree information given by  into the index, but does not actually &lt;strong&gt;update&lt;/strong&gt; any of the files it “caches”. (see: &lt;a href="https://git-scm.com/docs/git-checkout-index"&gt;git-checkout-index[1]&lt;/a&gt;)&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git read-tree 88e38705fdbd3608cddbe904b67c731f3234c45b
&lt;span class="nv"&gt;$ &lt;/span&gt;git ls-files &lt;span class="nt"&gt;-s&lt;/span&gt;
100644 ce013625030ba8dba906f756967f9e9ca394464a 0 hello.txt
100644 cc628ccd10742baea8241c5924df992b5c019f71 0 world.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Note however, that we still &lt;strong&gt;don’t&lt;/strong&gt; have the files on our file system, since we’re writing values &lt;strong&gt;directly&lt;/strong&gt; to the Git datastore. In order to “checkout” the files, we’ll use the &lt;code&gt;git-checkout-index&lt;/code&gt; command, which copies files from the index to the working tree:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout-index 0 &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-a&lt;/code&gt; stands for “all”. Now we should be able to see our files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls
&lt;/span&gt;hello.txt world.txt
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;hello.txt
hello
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;world.txt
world
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Summary 📝
&lt;/h3&gt;

&lt;p&gt;In this article, we stored two files directly to the Git datastore. The files weren’t yet visible to our local filesystem. We’ve created a tree and associated the two “blobs” to it, and then we brought the files to our working directory using the git-checkout-index command.&lt;/p&gt;

</description>
      <category>git</category>
    </item>
    <item>
      <title>Auto Link to Reference External Resources Based on the Reference ID in the Commit Message</title>
      <dc:creator>Maroun Maroun</dc:creator>
      <pubDate>Wed, 01 Jul 2020 13:43:46 +0000</pubDate>
      <link>https://dev.to/marounmaroun/auto-link-to-reference-external-resources-based-on-the-reference-id-in-the-commit-message-1ii0</link>
      <guid>https://dev.to/marounmaroun/auto-link-to-reference-external-resources-based-on-the-reference-id-in-the-commit-message-1ii0</guid>
      <description>&lt;p&gt;&lt;a href="https://help.github.com/en/github/administering-a-repository/configuring-autolinks-to-reference-external-resources"&gt;Configuring auto links to reference external resources&lt;/a&gt; is one of the most helpful features of GitHub.&lt;/p&gt;

&lt;p&gt;Configuring it will make the commit message clickable, and it'll reference the external resource (i.e. Jira).&lt;/p&gt;

&lt;p&gt;I thought it'd be very useful if you could do the same but from the CLI. So I wrote a &lt;a href="https://github.com/MarounMaroun/gitlink"&gt;simple script&lt;/a&gt; that does that.&lt;/p&gt;

&lt;p&gt;You should have two variables set:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;REFERENCE_PATTERN&lt;/code&gt; - Pattern used in commit message&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TARGET_URL&lt;/code&gt; - Link to the external system you want to link to&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, to link Jira issues having pattern like "PS-1425", you should set &lt;code&gt;REFERENCE_PATTERN&lt;/code&gt; to &lt;code&gt;PS-\d\d\d\d&lt;/code&gt;, and the &lt;code&gt;TARGET_URL&lt;/code&gt; should be set to &lt;code&gt;https://proteantecs.atlassian.net/browse&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Once set, you simply run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;gitlink &amp;lt;SHA&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If only one issue is referenced in the commit message, it'll be opened in the browser. Otherwise, you'll get a list of links for the issue.&lt;/p&gt;

&lt;p&gt;For example, having the following log:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Author: MarounMaroun &amp;lt;****  .com&amp;gt;
Date:   Tue Jun 30 23:16:30 2020 +0300

    BD-5562: handle missing user in the user service
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When you run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;gitlink 7d21af686732bd1812f79c4c51ac98a903de5c3d
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;A new tab with the relevant issue will be opened:&lt;/p&gt;

&lt;p&gt;Project in GitHub: &lt;a href="https://github.com/MarounMaroun/gitlink"&gt;https://github.com/MarounMaroun/gitlink&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>cli</category>
      <category>bash</category>
    </item>
    <item>
      <title>GitHub Bash API</title>
      <dc:creator>Maroun Maroun</dc:creator>
      <pubDate>Wed, 10 Jun 2020 19:32:47 +0000</pubDate>
      <link>https://dev.to/marounmaroun/github-bash-api-3lbl</link>
      <guid>https://dev.to/marounmaroun/github-bash-api-3lbl</guid>
      <description>&lt;p&gt;I'm writing &lt;a href="https://github.com/MarounMaroun/github-bash-api"&gt;Bash scripts&lt;/a&gt; for the &lt;a href="https://developer.github.com/v3/"&gt;GitHub API&lt;/a&gt; in Bash.&lt;/p&gt;

&lt;p&gt;This repo aims to expose basic functions for using the GitHub API in Bash, without any dependency on GitHub CLI tools.&lt;/p&gt;

&lt;p&gt;You can copy any of the functions and use it wherever you want. For example, in your own GitHub action script.&lt;/p&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;Each file aggregates functions that are relevant for the specific API.&lt;/p&gt;

&lt;p&gt;For example, the &lt;code&gt;pull_request.sh&lt;/code&gt; script have functions that expose the &lt;a href="https://developer.github.com/v3/pulls/"&gt;Pull Requests API&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can test each function by simply calling it inside the file. For example, to get the PRs count in some repository, you can call the &lt;code&gt;prs_count&lt;/code&gt; function in the &lt;code&gt;pull_requests.sh&lt;/code&gt; file, and then execute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;./pull_request.sh &amp;lt;token&amp;gt; &amp;lt;owner&amp;gt; &amp;lt;repo&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Which yields the number of PRs for the given repository.&lt;/p&gt;

&lt;p&gt;I hope you find it useful! Your input is highly welcomed and appreciated.&lt;/p&gt;

&lt;p&gt;Link to the repository: &lt;a href="https://github.com/MarounMaroun/github-bash-api"&gt;https://github.com/MarounMaroun/github-bash-api&lt;/a&gt;&lt;/p&gt;

</description>
      <category>github</category>
      <category>bash</category>
      <category>api</category>
    </item>
    <item>
      <title>My First GitHub Action!</title>
      <dc:creator>Maroun Maroun</dc:creator>
      <pubDate>Fri, 29 May 2020 18:33:52 +0000</pubDate>
      <link>https://dev.to/marounmaroun/my-first-github-action-1edp</link>
      <guid>https://dev.to/marounmaroun/my-first-github-action-1edp</guid>
      <description>&lt;p&gt;I wrote a &lt;a href="https://github.com/MarounMaroun/shell-checker"&gt;GitHub action&lt;/a&gt; for running &lt;a href="https://www.shellcheck.net/"&gt;ShellCheck&lt;/a&gt; on shell files in your PR.&lt;/p&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;Create a file &lt;code&gt;checker.yml&lt;/code&gt; inside &lt;code&gt;.github/workflows&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;pull_request&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;shell-check&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Shell Checker&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v2&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;marounmaroun/shell-checker@v1&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;GITHUB_TOKEN&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.GITHUB_TOKEN }}&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;info'&lt;/span&gt;
          &lt;span class="na"&gt;exclude&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can set the severity to one of: "error, warning, info, style". Default is "info".&lt;/p&gt;

&lt;p&gt;You can also include type of warnings to exclude. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;exclude&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SC2006,SC2148'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Default value is not set, meaning that there will be no exclusions.&lt;/p&gt;

&lt;p&gt;Code is available here: &lt;a href="https://github.com/MarounMaroun/shell-checker"&gt;https://github.com/MarounMaroun/shell-checker&lt;/a&gt;&lt;/p&gt;

</description>
      <category>github</category>
      <category>bash</category>
    </item>
    <item>
      <title>What Does "\K" Mean in Regex?</title>
      <dc:creator>Maroun Maroun</dc:creator>
      <pubDate>Mon, 20 Apr 2020 06:10:18 +0000</pubDate>
      <link>https://dev.to/marounmaroun/what-does-k-mean-in-regex-4l6n</link>
      <guid>https://dev.to/marounmaroun/what-does-k-mean-in-regex-4l6n</guid>
      <description>&lt;p&gt;Since not all regex flavors support &lt;a href="https://www.regular-expressions.info/lookaround.html"&gt;lookarounds&lt;/a&gt;, Perl introduced the &lt;a href="https://riptutorial.com/regex/topic/1338/match-reset---k"&gt;match reset - &lt;code&gt;\K&lt;/code&gt;&lt;/a&gt; (bolded is mine):&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;\K&lt;/code&gt; resets the starting point of the reported match. &lt;strong&gt;Any previously consumed characters are no longer included in the final match&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To make the explanation short, consider the following simple Regex:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a\Kb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When "b" is matched, &lt;code&gt;\K&lt;/code&gt; tells the Regex engine to &lt;em&gt;pretend&lt;/em&gt; that the match attempt started at this position.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'hello world'&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-oP&lt;/span&gt; &lt;span class="s1"&gt;'hello \K(world)'&lt;/span&gt;
world
~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'hello world'&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-oP&lt;/span&gt; &lt;span class="s1"&gt;'hello (world)'&lt;/span&gt;
hello world
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>regex</category>
      <category>bash</category>
      <category>grep</category>
    </item>
    <item>
      <title>What Does "--" (Double-Dash) Mean?</title>
      <dc:creator>Maroun Maroun</dc:creator>
      <pubDate>Thu, 19 Mar 2020 08:59:21 +0000</pubDate>
      <link>https://dev.to/marounmaroun/what-does-double-dash-mean-4289</link>
      <guid>https://dev.to/marounmaroun/what-does-double-dash-mean-4289</guid>
      <description>&lt;p&gt;From &lt;code&gt;man bash&lt;/code&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;--&lt;/code&gt;        A  &lt;code&gt;--&lt;/code&gt;  signals  the  end of options and disables further option processing.  Any arguments after the &lt;code&gt;--&lt;/code&gt; are treated as&lt;br&gt;
                 filenames and arguments.  An argument of &lt;code&gt;-&lt;/code&gt; is equivalent to &lt;code&gt;--&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In other words, &lt;code&gt;--&lt;/code&gt; is used to signify the &lt;strong&gt;end of command options&lt;/strong&gt;. After it, only positional parameters are accepted.&lt;/p&gt;

&lt;p&gt;For example, we want to look for the "--color" string using &lt;code&gt;grep&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"hello --color"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;--color&lt;/span&gt;
usage: &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;-abcDEFGHhIiJLlmnOoqRSsUVvwxZ&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;-A&lt;/span&gt; num] &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;-B&lt;/span&gt; num] &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;-C&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;num]]
    &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;-e&lt;/span&gt; pattern] &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;-f&lt;/span&gt; file] &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;--binary-files&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;value] &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;--color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;when]
    &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;--context&lt;/span&gt;&lt;span class="o"&gt;[=&lt;/span&gt;num]] &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;--directories&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;action] &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;--label&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;--line-buffered&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
    &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;--null&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;pattern] &lt;span class="o"&gt;[&lt;/span&gt;file ...]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We got an error, since &lt;code&gt;--color&lt;/code&gt; expect a value. We can fix by signaling the end of options to the grep command using &lt;code&gt;--&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"hello --color"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nt"&gt;--color&lt;/span&gt;
hello &lt;span class="nt"&gt;--color&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It's important to note that not all bash builtin commands accept the &lt;code&gt;--&lt;/code&gt; as an end-of-options marker.&lt;/p&gt;

</description>
      <category>bash</category>
    </item>
    <item>
      <title>mycontribution - View Your Contribution Graph From the Terminal</title>
      <dc:creator>Maroun Maroun</dc:creator>
      <pubDate>Tue, 17 Mar 2020 07:09:33 +0000</pubDate>
      <link>https://dev.to/marounmaroun/mycontribution-view-your-contribution-graph-from-the-terminal-3pgp</link>
      <guid>https://dev.to/marounmaroun/mycontribution-view-your-contribution-graph-from-the-terminal-3pgp</guid>
      <description>&lt;p&gt;I wrote a script for fun, that brings your contribution graph to the terminal:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TASHNipJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9ubg7ih0tvijxz084hg3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TASHNipJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9ubg7ih0tvijxz084hg3.png" alt="GitHub"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code (&lt;a href="https://github.com/MarounMaroun/mycontribution"&gt;GitHub link&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="nv"&gt;username&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;
&lt;span class="nv"&gt;symbol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;2&lt;/span&gt;&lt;span class="k"&gt;:-&lt;/span&gt;&lt;span class="p"&gt;▣&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="nv"&gt;$username&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Usage: mycontribution &amp;lt;username&amp;gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi

&lt;/span&gt;&lt;span class="nb"&gt;declare&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;months&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;&lt;span class="s2"&gt;"   J a n"&lt;/span&gt; &lt;span class="s2"&gt;"  F e b"&lt;/span&gt; &lt;span class="s2"&gt;"M a r"&lt;/span&gt; &lt;span class="s2"&gt;"  A p r"&lt;/span&gt; &lt;span class="s2"&gt;"   M a y"&lt;/span&gt; &lt;span class="s2"&gt;"  J u n"&lt;/span&gt; &lt;span class="s2"&gt;"   J u l"&lt;/span&gt; &lt;span class="s2"&gt;"     A u g"&lt;/span&gt; &lt;span class="s2"&gt;"   S e p"&lt;/span&gt; &lt;span class="s2"&gt;"     O c t"&lt;/span&gt; &lt;span class="s2"&gt;"  N o v"&lt;/span&gt; &lt;span class="s2"&gt;"    D e c"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;currentMonth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; +%-m&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nt"&gt;-1&lt;/span&gt;
&lt;span class="nv"&gt;months&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;months&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;:&lt;span class="nv"&gt;$currentMonth&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;months&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;::&lt;span class="nv"&gt;$currentMonth&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="nb"&gt;declare&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;graph&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; https://github.com/&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;rect class="day"'&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-oP&lt;/span&gt; &lt;span class="s1"&gt;'(?&amp;lt;=fill=").*?(?=" )'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$graph&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"User &lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt; doesn't exist"&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# print months&lt;/span&gt;
&lt;span class="nb"&gt;echo
&lt;/span&gt;&lt;span class="k"&gt;for &lt;/span&gt;month &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;months&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"%s"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$month&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done

&lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"   "&lt;/span&gt;
&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;" %s"&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;months&lt;/span&gt;&lt;span class="p"&gt;[0]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# print contribution graph&lt;/span&gt;
&lt;span class="nb"&gt;echo
&lt;/span&gt;&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-le&lt;/span&gt; 6 &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    for&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt; &lt;span class="nv"&gt;n&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;n&amp;lt;&lt;span class="k"&gt;${#&lt;/span&gt;&lt;span class="nv"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;n+&lt;span class="o"&gt;=&lt;/span&gt;7 &lt;span class="o"&gt;))&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
        if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"#c6e48b"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
            &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[38;5;71m&lt;/span&gt;&lt;span class="nv"&gt;$symbol&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[0m|"&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"#7bc96f"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
            &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[38;5;64m&lt;/span&gt;&lt;span class="nv"&gt;$symbol&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[0m|"&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"#239a3b"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
            &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[38;5;22m&lt;/span&gt;&lt;span class="nv"&gt;$symbol&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[0m|"&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"#196127"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
            &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[38;5;238m&lt;/span&gt;&lt;span class="nv"&gt;$symbol&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[0m|"&lt;/span&gt;
        &lt;span class="c"&gt;# no contribution&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"#ebedf0"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
            &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[38;5;252m&lt;/span&gt;&lt;span class="nv"&gt;$symbol&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[0m|"&lt;/span&gt;
        &lt;span class="k"&gt;fi
    done
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;
    &lt;span class="o"&gt;((&lt;/span&gt; i++ &lt;span class="o"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;done
&lt;/span&gt;&lt;span class="nb"&gt;echo
printf&lt;/span&gt; &lt;span class="s2"&gt;"Less &lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[38;5;252m&lt;/span&gt;&lt;span class="nv"&gt;$symbol&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[0m|&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[38;5;71m&lt;/span&gt;&lt;span class="nv"&gt;$symbol&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[0m|&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[38;5;64m&lt;/span&gt;&lt;span class="nv"&gt;$symbol&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[0m|&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[38;5;22m&lt;/span&gt;&lt;span class="nv"&gt;$symbol&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[0m|&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[38;5;238m&lt;/span&gt;&lt;span class="nv"&gt;$symbol&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;e[0m More"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Enjoy :)&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
      <category>bash</category>
    </item>
    <item>
      <title>"Git checkouter" - A Simple Tool to Checkout, List or Rebase Your Git Projects</title>
      <dc:creator>Maroun Maroun</dc:creator>
      <pubDate>Sun, 15 Mar 2020 07:51:36 +0000</pubDate>
      <link>https://dev.to/marounmaroun/git-checkouter-a-simple-tool-to-checkout-list-or-rebase-your-git-projects-50kh</link>
      <guid>https://dev.to/marounmaroun/git-checkouter-a-simple-tool-to-checkout-list-or-rebase-your-git-projects-50kh</guid>
      <description>&lt;p&gt;The project is available on GitHub, on the &lt;a href="https://github.com/MarounMaroun/git-checkouter"&gt;following link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git-checkouter&lt;/code&gt; is a tool that iterates on your parent Git folder, which includes all of your Git projects, and checkouts, lists, or rebase on top of master the given branch for each project.&lt;/p&gt;

&lt;h3&gt;
  
  
  What?
&lt;/h3&gt;

&lt;p&gt;OK, it's a common practice to keep all of your work-related Git projects in some folder, let's say &lt;code&gt;~work&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.
├── project1
├── project2
├── project3
├── project4
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now you are working on a ticket "xxx", and you changed projects 1, 2 and 4.&lt;/p&gt;

&lt;p&gt;Imagine you have many more projects, and you're working on many more tickets. Now you want to run local tests for the feature "xxx", but you don't remember what projects you have changed for this feature:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./git-checkouter.sh &lt;span class="nt"&gt;-p&lt;/span&gt; ~/work &lt;span class="nt"&gt;-b&lt;/span&gt; xxx &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;span class="s1"&gt;'xxx'&lt;/span&gt; found &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s1"&gt;'project1'&lt;/span&gt;
&lt;span class="s1"&gt;'xxx'&lt;/span&gt; found &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s1"&gt;'project2'&lt;/span&gt;
&lt;span class="s1"&gt;'xxx'&lt;/span&gt; found &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s1"&gt;'project4'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;providing &lt;code&gt;-d&lt;/code&gt; will only list which projects include the branch, and will not actually checkout.&lt;/p&gt;

&lt;p&gt;It is also possible to set an environment variable: &lt;code&gt;export PROJECTS_DIR=~/work&lt;/code&gt; and omit the &lt;code&gt;-p&lt;/code&gt; flag.&lt;/p&gt;

&lt;p&gt;After you saw which projects you changed for that specific feature, you can checkout the branch in all of them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./git-checkouter.sh &lt;span class="nt"&gt;-p&lt;/span&gt; ~/work &lt;span class="nt"&gt;-b&lt;/span&gt; xxx
project1: Switched to branch &lt;span class="s1"&gt;'xxx'&lt;/span&gt;
project2: Switched to branch &lt;span class="s1"&gt;'xxx'&lt;/span&gt;
project3: Switched to branch &lt;span class="s1"&gt;'xxx'&lt;/span&gt;
project4: Switched to branch &lt;span class="s1"&gt;'xxx'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you want to ignore some projects, you can provide the &lt;code&gt;-e&lt;/code&gt; flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./git-checkouter.sh &lt;span class="nt"&gt;-p&lt;/span&gt; ~/work &lt;span class="nt"&gt;-b&lt;/span&gt; master &lt;span class="nt"&gt;-e&lt;/span&gt; project2,project3
project1: Switched to branch &lt;span class="s1"&gt;'xxx'&lt;/span&gt;
Project excluded: project2
Project excluded: project3
project4: Switched to branch &lt;span class="s1"&gt;'xxx'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Sync all branches with the remote master using the &lt;code&gt;-f&lt;/code&gt; flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./git-checkouter.sh &lt;span class="nt"&gt;-p&lt;/span&gt; ~/work &lt;span class="nt"&gt;-f&lt;/span&gt;
Rebasing project1: Current branch master is up to date.
Rebasing project2: Fast-forwarded xxx to origin/master.
Rebasing project3: Current branch xxx is up to date.
Rebasing project4: Current branch xxx is up to date.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="nv"&gt;CYAN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'\033[1;36m'&lt;/span&gt;
&lt;span class="nv"&gt;NC&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'\033[0m'&lt;/span&gt;
&lt;span class="nv"&gt;YELLOW&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'\033[0;33m'&lt;/span&gt;

display_usage&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Usage: &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;basename&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt; [OPTIONS]"&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  -p  path to your projects' dir. If not provided,"&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"        will use env variable 'PROJECTS_DIR'"&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  -b  git branch to checkout"&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  -d  only print projects that have the given branch,"&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"        without actually check it out"&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  -e  projects to exclude, separated by &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; without spaces"&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  -f  rebase all directories on top of remote master branch"&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Bugs and suggestions: &amp;lt;https://github.com/MarounMaroun/git-checkouter/issues&amp;gt;"&lt;/span&gt;
  &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="nv"&gt;projects&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$PROJECTS_DIR&lt;/span&gt;
&lt;span class="nv"&gt;dry&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;
&lt;span class="nv"&gt;branch&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;
&lt;span class="nv"&gt;exclude&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;
&lt;span class="nv"&gt;fetch&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;

&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;getopts&lt;/span&gt; &lt;span class="s1"&gt;'p:b:de:f'&lt;/span&gt; flag&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
  case&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;flag&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="k"&gt;in
    &lt;/span&gt;p&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="nv"&gt;projects&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;OPTARG&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;;;&lt;/span&gt;
    b&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="nv"&gt;branch&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;OPTARG&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;;;&lt;/span&gt;
    d&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="nv"&gt;dry&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"true"&lt;/span&gt;
      &lt;span class="p"&gt;;;&lt;/span&gt;
    e&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="nv"&gt;exclude&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;OPTARG&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;;;&lt;/span&gt;
    f&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="nv"&gt;fetch&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"true"&lt;/span&gt;
      &lt;span class="p"&gt;;;&lt;/span&gt;
    &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      display_usage
      &lt;span class="nb"&gt;exit &lt;/span&gt;1
      &lt;span class="p"&gt;;;&lt;/span&gt;
  &lt;span class="k"&gt;esac&lt;/span&gt;
&lt;span class="k"&gt;done

if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$branch&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$projects&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$fetch&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Error: both branch and projects dirs must be specified,"&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"unless you're using -f flag"&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
  display_usage
&lt;span class="k"&gt;fi

if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$exclude&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nv"&gt;IFS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;','&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; exclude_projects &lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="nv"&gt;$exclude&lt;/span&gt;
&lt;span class="k"&gt;fi

for &lt;/span&gt;d &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$projects&lt;/span&gt;/&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nv"&gt;project_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;basename&lt;/span&gt; &lt;span class="nv"&gt;$d&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$d&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi
  &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="nv"&gt;$d&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s2"&gt;".git"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$fetch&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
      &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"Rebasing branch &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;CYAN&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;basename&lt;/span&gt; &lt;span class="nv"&gt;$d&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;NC&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
      git fetch &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; git rebase origin/master
      &lt;span class="k"&gt;continue
    fi
    &lt;/span&gt;&lt;span class="nv"&gt;branches&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;git branch | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; 3-&lt;span class="si"&gt;)&lt;/span&gt;
    &lt;span class="nv"&gt;branch_found&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$branches&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-oP&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\b&lt;/span&gt;&lt;span class="nv"&gt;$branch&lt;/span&gt;&lt;span class="se"&gt;\b&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$branch_found&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi
    if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$dry&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
      &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"'&lt;/span&gt;&lt;span class="nv"&gt;$branch&lt;/span&gt;&lt;span class="s2"&gt;' found in &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;CYAN&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;'&lt;/span&gt;&lt;span class="nv"&gt;$project_name&lt;/span&gt;&lt;span class="s2"&gt;'&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;NC&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;else
      &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;CYAN&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;basename&lt;/span&gt; &lt;span class="nv"&gt;$d&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;NC&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
      &lt;span class="nv"&gt;project_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;basename&lt;/span&gt; &lt;span class="nv"&gt;$d&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$exclude_projects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;~ .&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;$project_name&lt;/span&gt;.&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;YELLOW&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;Project excluded:&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;NC&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$project_name&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
        &lt;span class="k"&gt;continue
      fi
      &lt;/span&gt;git checkout &lt;span class="nv"&gt;$branch&lt;/span&gt;
    &lt;span class="k"&gt;fi
  fi
done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>git</category>
      <category>bash</category>
    </item>
    <item>
      <title>Hello, K8s Spring Boot!</title>
      <dc:creator>Maroun Maroun</dc:creator>
      <pubDate>Tue, 25 Feb 2020 08:50:23 +0000</pubDate>
      <link>https://dev.to/marounmaroun/hello-k8s-spring-boot-17ah</link>
      <guid>https://dev.to/marounmaroun/hello-k8s-spring-boot-17ah</guid>
      <description>&lt;p&gt;Let's try to build the simplest Java Spring application that runs as a pod in a Kubernetes cluster.&lt;/p&gt;

&lt;p&gt;The full project can be found on my &lt;a href="https://github.com/MarounMaroun/spring-k8s-helloworld"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The project's structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;├── Dockerfile
├── README.md
├── build.gradle
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
├── k8s
│   └── depl.yaml
├── settings.gradle
└── src
    └── main
        └── java
            └── hello
                ├── App.java
                └── HelloWorldCtrl.java
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;App.java&lt;/code&gt; is our entry point:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;hello&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.boot.SpringApplication&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.boot.autoconfigure.SpringBootApplication&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@SpringBootApplication&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;SpringApplication&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and our controller simply returns "hello world" on the root path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;hello&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.web.bind.annotation.RestController&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.web.bind.annotation.RequestMapping&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@RestController&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HelloWorldCtrl&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@RequestMapping&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;index&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;"Greetings from Spring Boot!"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now let's write a Dockerfile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;FROM gradle:jdk10 as builder

COPY &lt;span class="nt"&gt;--chown&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gradle:gradle &lt;span class="nb"&gt;.&lt;/span&gt; /app
WORKDIR /app
RUN gradle build

EXPOSE 8080
WORKDIR /app

CMD java &lt;span class="nt"&gt;-jar&lt;/span&gt; build/libs/gs-spring-boot-0.1.0.jar
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It uses Gradle in order to build the application, and the &lt;code&gt;CMD&lt;/code&gt; instruction runs the JAR file.&lt;/p&gt;

&lt;p&gt;The K8s deployment is simple. It consists of a &lt;a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/"&gt;deployment&lt;/a&gt; and a &lt;a href="https://kubernetes.io/docs/concepts/services-networking/service/"&gt;service&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: hello-world
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: hello-world
        visualize: &lt;span class="s2"&gt;"true"&lt;/span&gt;
    spec:
      containers:
      - name: hello-world-pod
        image: marounbassam/hello-spring
        ports:
        - containerPort: 8080
&lt;span class="nt"&gt;---&lt;/span&gt;
apiVersion: v1
kind: Service
metadata:
  labels:
    visualize: &lt;span class="s2"&gt;"true"&lt;/span&gt;
  name: hello-world-service
spec:
  selector:
    app: hello-world
  ports:
  - name: http
    protocol: TCP
    port: 8080
    targetPort: 8080
  &lt;span class="nb"&gt;type&lt;/span&gt;: ClusterIP
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The deployment defines two replicas of the pod that will be running the container that's built from the image specified in the image attribute.&lt;/p&gt;

&lt;p&gt;The service is of type &lt;code&gt;ClusterIP&lt;/code&gt; (the default Kubernetes service). It gives us a service inside our cluster that other apps can access.&lt;/p&gt;

&lt;p&gt;Creating the resources in your cluster:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl create &lt;span class="nt"&gt;-f&lt;/span&gt; &amp;lt;yaml_file&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The resources can be visualized as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;+---------------------+
| hello-world-service |
|                     |
|    10.15.242.210    |
+---------O-----------+
          |
          +-------------O--------------------------O
                        |                          |
              +---------O-----------+    +---------O-----------+
              |        pod 1        |    |        pod 2        |
              |                     |    |                     |
              |     hello-world     |    |     hello-world     |
              +---------------------+    +---------------------+
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Inside The Cluster
&lt;/h3&gt;

&lt;p&gt;If you're using minikube for running the cluster locally, you might encounter issues (I really don't know why). But if you're running on a cloud provider, or something more "serious" than minikube, you should be able to do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get pods
NAME                         READY     STATUS    RESTARTS   AGE
hello-world-5bb87c95-6h4kh   1/1       Running   0          7h
hello-world-5bb87c95-bz64v   1/1       Running   0          7h
&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get svc
NAME                  TYPE        CLUSTER-IP      EXTERNAL-IP   PORT&lt;span class="o"&gt;(&lt;/span&gt;S&lt;span class="o"&gt;)&lt;/span&gt;    AGE
hello-world-service   ClusterIP   10.15.242.210   &amp;lt;none&amp;gt;        8080/TCP   5s
kubernetes            ClusterIP   10.15.240.1     &amp;lt;none&amp;gt;        443/TCP    7h
&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; hello-world-5bb87c95-6h4kh bash
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;inside the pod&lt;span class="o"&gt;)&lt;/span&gt; curl 10.15.242.210:8080
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;inside the pod&lt;span class="o"&gt;)&lt;/span&gt; Greetings from Spring Boot!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you have any questions, please drop a comment.&lt;/p&gt;

</description>
      <category>java</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>Job Control Commands in Linux</title>
      <dc:creator>Maroun Maroun</dc:creator>
      <pubDate>Tue, 28 Jan 2020 20:08:02 +0000</pubDate>
      <link>https://dev.to/marounmaroun/job-control-commands-in-linux-1c76</link>
      <guid>https://dev.to/marounmaroun/job-control-commands-in-linux-1c76</guid>
      <description>&lt;p&gt;Job is simply a process. In Linux, each job is associated with PID.&lt;/p&gt;

&lt;p&gt;There are three types of jobs:&lt;/p&gt;

&lt;h3&gt;
  
  
  Foreground Jobs
&lt;/h3&gt;

&lt;p&gt;When you run &lt;code&gt;vi &amp;lt;file&amp;gt;&lt;/code&gt;, the &lt;code&gt;vi&lt;/code&gt; program "occupies" the terminal window, and the process runs in the &lt;strong&gt;foreground&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When you exit the program, the application is no longer running, and the process dies.&lt;/p&gt;

&lt;h3&gt;
  
  
  Background Jobs
&lt;/h3&gt;

&lt;p&gt;Processes that are running without occupying the window. This can be achieved, for example, by appending &lt;code&gt;&amp;amp;&lt;/code&gt; at the end of the command. For example, when you run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-czf&lt;/span&gt; file.tar.gz &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;the &lt;code&gt;tar&lt;/code&gt; process will block the terminal until it finishes. However, when you run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-czf&lt;/span&gt; file.tar.gz &lt;span class="nb"&gt;.&lt;/span&gt; &amp;amp;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;then it'll run in the background. And if you type &lt;code&gt;jobs&lt;/code&gt; while it's still running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;jobs&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;1]+  Running                 &lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-czf&lt;/span&gt; file.tar.gz &lt;span class="nb"&gt;.&lt;/span&gt; &amp;amp;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Stopped Jobs
&lt;/h3&gt;

&lt;p&gt;CTRL + z sends the &lt;code&gt;SIGTSTP&lt;/code&gt; signal that stops the job that's runnin in the foreground.&lt;/p&gt;

&lt;h3&gt;
  
  
  Job Control Commands
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;jobs&lt;/code&gt; - lists all jobs&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bg [PID...]&lt;/code&gt; - takes the specified job(s) to the background, resuming them if they are stopped.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fg [PID]&lt;/code&gt; - brings the specified job to the foreground, resuming it if it is stopped&lt;/li&gt;
&lt;li&gt;
CTRL + z - Sends the &lt;code&gt;SIGTSTP&lt;/code&gt; signal that stops the running job&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The following should demonstrate the commands above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-czf&lt;/span&gt; file.tar.gz &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;span class="c"&gt;# ...working...&lt;/span&gt;
&lt;span class="c"&gt;# CTRL + z&lt;/span&gt;
Job 1, &lt;span class="s1"&gt;'tar -czf file.tar.gz .'&lt;/span&gt; has stopped
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;jobs&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;1]+  Running                 &lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-czf&lt;/span&gt; file.tar.gz &lt;span class="nb"&gt;.&lt;/span&gt; &amp;amp;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;fg&lt;/span&gt; %1 &lt;span class="o"&gt;(&lt;/span&gt;or just &lt;span class="s2"&gt;"fg"&lt;/span&gt; since there&lt;span class="s1"&gt;'s only one job)
# job restarts
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That's all :)&lt;/p&gt;

</description>
      <category>linux</category>
    </item>
    <item>
      <title>Why Stack Overflow Is Part of My Daily Routine</title>
      <dc:creator>Maroun Maroun</dc:creator>
      <pubDate>Sun, 26 Jan 2020 11:43:32 +0000</pubDate>
      <link>https://dev.to/marounmaroun/why-stack-overflow-is-part-of-my-daily-routine-40b8</link>
      <guid>https://dev.to/marounmaroun/why-stack-overflow-is-part-of-my-daily-routine-40b8</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;It is literally true that you can succeed best and quickest by helping others to succeed - Napoleon Hill&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you've ever been interested in programming or anything related to and been around the net long enough, you've come across Stack Overflow, accidentally or on purpose.&lt;/p&gt;

&lt;p&gt;What is &lt;a href="https://stackoverflow.com/tour"&gt;Stack Overflow&lt;/a&gt;?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Stack Overflow is a question and answer site for professional and enthusiast programmers. It's built and run by you as part of the Stack Exchange network of Q&amp;amp;A sites. With your help, we're working together to build a library of detailed answers to every question about programming&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It was in 2013 when I asked my first question in Stack Overflow, got down-voted and my question was closed. Back then, I didn't know why was that 🤷‍♂️ all that I asked for was &lt;strong&gt;a solution for my homework&lt;/strong&gt;, and by saying "solution" I mean a full solution. I didn't expect comments like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You should solve your homework by yourself&lt;/li&gt;
&lt;li&gt;What have you tried?&lt;/li&gt;
&lt;li&gt;Be more detailed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It was an easy question for professional programmers who live in Stack Overflow, why are they being offensive?&lt;/p&gt;

&lt;p&gt;After leaving the community, disappointed, for a couple of months, I decided to take another risk and ask another one. It was a practical and detailed question. Some senior members edited my question, fixed some typos and reformatted it, making it look much better.&lt;/p&gt;

&lt;p&gt;Not only that I was up-voted, got a detailed answer, learned how to ask and got some points, but I was also &lt;strong&gt;encouraged&lt;/strong&gt; and informed that I was really close to the solution.&lt;/p&gt;

&lt;p&gt;I began visiting Stack Overflow &lt;em&gt;on a daily basis&lt;/em&gt;, just to check if my question has new answers or comments. While hanging out there, I saw a very similar question to mine, I knew the answer! But just before I posted it, I had to verify it's good by opening my IDE, running the code and validating it - By doing so, I was more confident about the subject being discussed and I better understood the problem!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Knowledge has to be improved, challenged, and increased constantly, or it vanishes - Peter Drucker&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;By navigating through Stach Overflow, I get exposed to new fields and keep atop new technologies, I can choose what subjects I'm interested in and filter questions accordingly.&lt;/p&gt;

&lt;p&gt;Every day I learn something new through reading more posts from users. Sometimes I find myself investigating questions that I came across because I was curious about, I challenge myself to find a solution to that problem. By doing this, I do research, I try new things, I dive into other fields and not only that I'm helping the original poster, but I'm learning new things. I can get comments to my answers and improve them, I can comment on answers, edit answers and questions, vote on them and more.&lt;/p&gt;

&lt;p&gt;Stack Overflow is &lt;em&gt;the&lt;/em&gt; place for programming questions, it's an endless source of knowledge, use it.&lt;/p&gt;

</description>
      <category>stackoverflow</category>
    </item>
    <item>
      <title>Meet "gh" - the Official GitHub CLI</title>
      <dc:creator>Maroun Maroun</dc:creator>
      <pubDate>Tue, 21 Jan 2020 07:34:50 +0000</pubDate>
      <link>https://dev.to/marounmaroun/meet-gh-the-official-github-cli-25db</link>
      <guid>https://dev.to/marounmaroun/meet-gh-the-official-github-cli-25db</guid>
      <description>&lt;p&gt;&lt;code&gt;gh&lt;/code&gt; is a new CLI that enables you to work seamlessly with GitHub on the command line.&lt;/p&gt;

&lt;p&gt;As of the date of writing this post, the tool is still in its early stages of development.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install github/gh/gh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;p&gt;With &lt;code&gt;gh&lt;/code&gt;, you can create, view, and checkout pull-requests. You can also create and view issues. Let's view its options:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;gh &lt;span class="nb"&gt;pr &lt;/span&gt;create &lt;span class="nt"&gt;--help&lt;/span&gt;
Create a pull request

Usage:
  gh &lt;span class="nb"&gt;pr &lt;/span&gt;create &lt;span class="o"&gt;[&lt;/span&gt;flags]

Flags:
  &lt;span class="nt"&gt;-B&lt;/span&gt;, &lt;span class="nt"&gt;--base&lt;/span&gt; string    The branch into which you want your code merged
  &lt;span class="nt"&gt;-b&lt;/span&gt;, &lt;span class="nt"&gt;--body&lt;/span&gt; string    Supply a body. Will prompt &lt;span class="k"&gt;for &lt;/span&gt;one otherwise.
  &lt;span class="nt"&gt;-d&lt;/span&gt;, &lt;span class="nt"&gt;--draft&lt;/span&gt;          Mark pull request as a draft
  &lt;span class="nt"&gt;-t&lt;/span&gt;, &lt;span class="nt"&gt;--title&lt;/span&gt; string   Supply a title. Will prompt &lt;span class="k"&gt;for &lt;/span&gt;one otherwise.
  &lt;span class="nt"&gt;-w&lt;/span&gt;, &lt;span class="nt"&gt;--web&lt;/span&gt;            Open the web browser to create a pull request

Global Flags:
      &lt;span class="nt"&gt;--help&lt;/span&gt;              Show &lt;span class="nb"&gt;help &lt;/span&gt;&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="nb"&gt;command&lt;/span&gt;
  &lt;span class="nt"&gt;-R&lt;/span&gt;, &lt;span class="nt"&gt;--repo&lt;/span&gt; OWNER/REPO   Select another repository using the OWNER/REPO format
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now let's create a simple PR:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;gh &lt;span class="nb"&gt;pr &lt;/span&gt;create &lt;span class="nt"&gt;--base&lt;/span&gt; master

Creating pull request &lt;span class="k"&gt;for &lt;/span&gt;test_branch into master &lt;span class="k"&gt;in &lt;/span&gt;MarounMaroun/git_examples
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We'll now be prompted to enter the PR title:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;gh &lt;span class="nb"&gt;pr &lt;/span&gt;create &lt;span class="nt"&gt;--base&lt;/span&gt; master

Creating pull request &lt;span class="k"&gt;for &lt;/span&gt;test_branch into master &lt;span class="k"&gt;in &lt;/span&gt;MarounMaroun/git_examples

? Title My first PR from CLI!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Continuing with the prompt, we'll be asked to enter the PR's description, and finally a validation window:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;? Submit?  &lt;span class="o"&gt;[&lt;/span&gt;Use arrows to move, &lt;span class="nb"&gt;type &lt;/span&gt;to filter]
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; Yes
  Edit
  Cancel
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After hitting "Yes", the PR will be created for us:&lt;/p&gt;

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

&lt;p&gt;Feel free to explore the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;gh &lt;span class="nt"&gt;--help&lt;/span&gt;
gh &lt;span class="nb"&gt;pr&lt;/span&gt; &lt;span class="nt"&gt;--help&lt;/span&gt;
gh &lt;span class="nb"&gt;pr &lt;/span&gt;create &lt;span class="nt"&gt;--help&lt;/span&gt;
gh issue view &lt;span class="nt"&gt;--help&lt;/span&gt;
&lt;span class="c"&gt;# and so on...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>git</category>
      <category>github</category>
    </item>
  </channel>
</rss>
