<?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>Forem: Daniel 📎</title>
    <description>The latest articles on Forem by Daniel 📎 (@sadasant).</description>
    <link>https://forem.com/sadasant</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%2F184172%2Fd89c9901-3082-477e-bed6-459d57b4203c.jpg</url>
      <title>Forem: Daniel 📎</title>
      <link>https://forem.com/sadasant</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sadasant"/>
    <language>en</language>
    <item>
      <title>Quick access to the most relevant folder</title>
      <dc:creator>Daniel 📎</dc:creator>
      <pubDate>Fri, 21 Jun 2019 19:06:50 +0000</pubDate>
      <link>https://forem.com/sadasant/quick-access-to-the-most-relevant-folder-khg</link>
      <guid>https://forem.com/sadasant/quick-access-to-the-most-relevant-folder-khg</guid>
      <description>&lt;p&gt;If anyone else is a terminal fan like I am, I think you might like this. Being part of &lt;a href="https://github.com/Azure/azure-sdk-for-js"&gt;azure-sdk-for-js&lt;/a&gt; has presented me with a new set of challenges, one of them being to navigate deep in folders to get where proposed changes are located. To aid in this, I made this little bash script that changes directory to the parent folder common to all the changes in the current branch. I'm enjoying it so far! Let me know if you like it or if you have any feedback &amp;lt;3&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;About the name:&lt;/strong&gt; &lt;code&gt;csd&lt;/code&gt; is fine to me since I'm using this a lot, just like one would use &lt;code&gt;cd&lt;/code&gt;. You might prefer to use a different name for clarity.&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;# csd: "changes' directory", as in the directory of the changes.&lt;/span&gt;
&lt;span class="c"&gt;# Changes the directory to the common parent to all the changes in current branch.&lt;/span&gt;
&lt;span class="c"&gt;# Specially useful to switch to the folder relevant to the changes that a specific branch or Pull Request makes in a large project.&lt;/span&gt;
&lt;span class="c"&gt;# By default acts based on the current changes to the current branch, but another target can be specified by passing a single argument.&lt;/span&gt;
&lt;span class="c"&gt;# Example: csd master # changes to the common parent relative to the master branch.&lt;/span&gt;
&lt;span class="c"&gt;# Source of the regexp: https://stackoverflow.com/a/17475354&lt;/span&gt;
&lt;span class="k"&gt;function &lt;/span&gt;csd&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
 &lt;span class="nv"&gt;common_prefix&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;git diff &lt;span class="nv"&gt;$1&lt;/span&gt; &lt;span class="nt"&gt;--name-only&lt;/span&gt; | &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s1"&gt;'N;s/^\(.*\).*\n\1.*$/\1\n\1/;D'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt; 
 &lt;span class="nv"&gt;common_parent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;common_prefix&lt;/span&gt;&lt;span class="p"&gt;%/*&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
 &lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;git rev-parse &lt;span class="nt"&gt;--show-toplevel&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;/&lt;span class="nv"&gt;$common_parent&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>bash</category>
      <category>git</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
