<?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: Tom Benevides</title>
    <description>The latest articles on DEV Community by Tom Benevides (@devatreides).</description>
    <link>https://dev.to/devatreides</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%2F158801%2F59499175-1c64-4a6b-9386-e774bd36d50b.jpg</url>
      <title>DEV Community: Tom Benevides</title>
      <link>https://dev.to/devatreides</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devatreides"/>
    <language>en</language>
    <item>
      <title>How to use multiple GIT accounts per folder on Linux</title>
      <dc:creator>Tom Benevides</dc:creator>
      <pubDate>Mon, 22 Feb 2021 04:12:39 +0000</pubDate>
      <link>https://dev.to/devatreides/how-to-use-multiple-git-accounts-per-folder-on-linux-1h50</link>
      <guid>https://dev.to/devatreides/how-to-use-multiple-git-accounts-per-folder-on-linux-1h50</guid>
      <description>&lt;p&gt;Tipically, one of the first tools that a developer learns when starting the "dev journey" is &lt;strong&gt;git&lt;/strong&gt;. For those who still don't know much about this little guy, it was created by &lt;em&gt;Linus Benedict Torvalds&lt;/em&gt;, a Finnish software engineer, naturalized American, known as the creator of &lt;strong&gt;linux kernel&lt;/strong&gt;. Torvald's idea was to have a simple versioning system that met three requirements that he himself considered indispensable (and that other software couldn't guarantee):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It needed to be distributed;&lt;/li&gt;
&lt;li&gt;The performance had to be good;&lt;/li&gt;
&lt;li&gt;It needed to ensure that what was put in, was exactly what was obtained afterwards;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;According to him, these three parameters were sufficient to discard virtually all versioning systems until then, so he decided to build his own system.&lt;/p&gt;

&lt;h2&gt;
  
  
  A single git account on Linux: kid's stuff
&lt;/h2&gt;

&lt;p&gt;Everyone who has ever set up a local git user knows that it have no secrets. You define the user name and email and... that's it.&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.name &lt;span class="s2"&gt;"Tom Benevides"&lt;/span&gt;
git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.email &lt;span class="s2"&gt;"tombenevides@mail.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;From now on, all the repositories you create will use these credentials.&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;new_repo &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
git init
&lt;span class="nb"&gt;touch &lt;/span&gt;text.txt
git add text.txt
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"new file"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;And if I take a look at the &lt;em&gt;git log&lt;/em&gt;, this will be the result:&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;commit 036573401e5788917383a27fb6c2acf607f5e441 &lt;span class="o"&gt;(&lt;/span&gt;HEAD -&amp;gt; master&lt;span class="o"&gt;)&lt;/span&gt;
Author: Tom Benevides &amp;lt;tombenevides@mail.com&amp;gt;
Date:   Sun Feb 7 13:50:05 2021 &lt;span class="nt"&gt;-0400&lt;/span&gt;

   new file
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;So, everything is fine with our configuration but... what if my project uses a different account?&lt;/p&gt;

&lt;h2&gt;
  
  
  A git account per repository: still piece of cake, but it can be a little tricky
&lt;/h2&gt;

&lt;p&gt;We'll now create another repository. This is going to be the &lt;em&gt;work_repo&lt;/em&gt;. It actually uses a different email account because it's a company project and not a personal project like &lt;em&gt;new_repo&lt;/em&gt;.&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~
&lt;span class="nb"&gt;mkdir &lt;/span&gt;work_repo &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
git init
&lt;span class="nb"&gt;touch &lt;/span&gt;text.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;If we commit the changes now, my personal account (system default) will be registered, but I need to use the work email, &lt;a href="mailto:tombenevides@work.com"&gt;tombenevides@work.com&lt;/a&gt;. So, we need to configure the new credentials in the repository.&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;git config user.email &lt;span class="s2"&gt;"tombenevides@work.com"&lt;/span&gt;
git add text.txt
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"new file"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;Now, when committing, my registered email will be the work email.&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;commit f47e5c7140296c9fbe1f4fb001149b04b329b655 &lt;span class="o"&gt;(&lt;/span&gt;HEAD -&amp;gt; master&lt;span class="o"&gt;)&lt;/span&gt;
Author: Tom Benevides &amp;lt;tombenevides@work.com&amp;gt;
Date:   Sun Feb 7 14:05:02 2021 &lt;span class="nt"&gt;-0400&lt;/span&gt;

   new file
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;All right, happy ending? So-so. Now, imagine that you have several work repositories and several personal repositories. It will be a bit annoying that you have to configure the correct credential in each of the repositories. If your work account email changes or you have a new git account? You'll need to make the change in all repositories. Lot of job right? There're people who don't think so.&lt;/p&gt;

&lt;p&gt;Personally, what I can do to make my life simpler, I’m doing and a nice idea would be to configure git so that every time I create a repository in a given folder, the credentials I want are automatically assigned to it. And look how cool; git does that!&lt;/p&gt;

&lt;h2&gt;
  
  
  A git account per folder: the light at the end of the tunnel
&lt;/h2&gt;

&lt;p&gt;The idea is pretty simple: we'll have two base folders (&lt;em&gt;Work&lt;/em&gt; and &lt;em&gt;Personal&lt;/em&gt;) where the repositories will be stored according to their respective origin. All repositories within each base folder will use the same credentials, different from the default and without configuration by repository. Structure proposal below.&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;Projects
├── Personal
└── Work
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;Now, we need to tell git that the &lt;em&gt;Personal&lt;/em&gt; folder repositories will use the email "&lt;a href="mailto:tombenevides@newmail.com"&gt;tombenevides@newmail.com&lt;/a&gt;" and not the default email we set up earlier. To do this, in your home (&lt;code&gt;cd ~&lt;/code&gt;), create a file called &lt;code&gt;.gitconfig-personal&lt;/code&gt; and as content, simply recipient of the email.&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;user]
  email &lt;span class="o"&gt;=&lt;/span&gt; tombenevides@newmail.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;Once we set up the Personal folder credential, we will create a &lt;code&gt;.gitconfig-work&lt;/code&gt; file to set up work credential.&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;user]
  email &lt;span class="o"&gt;=&lt;/span&gt; tombenevides@work.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;With our config files created, we'll now edit the &lt;code&gt;.gitconfig&lt;/code&gt; file found in the user home (&lt;code&gt;cd ~&lt;/code&gt;) and let git know that whenever there is a repository inside the &lt;em&gt;Personal&lt;/em&gt; folder, it must use the credential of the &lt;code&gt;.gitconfi-personal&lt;/code&gt; file and every time there is a repository in the &lt;em&gt;Work&lt;/em&gt; folder, git must use the credential of the &lt;code&gt;.gitconfig-work&lt;/code&gt; file.&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;user]
    name &lt;span class="o"&gt;=&lt;/span&gt; Tom Benevides
    email &lt;span class="o"&gt;=&lt;/span&gt; tombenevides@mail.com
&lt;span class="o"&gt;[&lt;/span&gt;includeIf &lt;span class="s2"&gt;"gitdir:Projects/Personal/**"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
    path &lt;span class="o"&gt;=&lt;/span&gt; .gitconfig-personal
&lt;span class="o"&gt;[&lt;/span&gt;includeIf &lt;span class="s2"&gt;"gitdir:Projects/Work/**"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
    path &lt;span class="o"&gt;=&lt;/span&gt; .gitconfig-work
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;... and voilà! Now, the work repositories only need to be inside the &lt;code&gt;~/Projects/Work&lt;/code&gt; directory and all commits will use the correct credentials, without any configurations by repository. The same goes to the &lt;em&gt;Personal&lt;/em&gt; folder repositories. And if at any point, your work (or personal) git account email changes, just change the &lt;code&gt;.gitconfig-X&lt;/code&gt; file corresponding to the folder and all repositories inside will use the new credential.&lt;/p&gt;

&lt;p&gt;So... that's it! Try it and then tell me your experience in the comments, via &lt;a href="https://twitter.com/tongedev"&gt;Twitter&lt;/a&gt; or &lt;a href="https://www.instagram.com/tomb.dev"&gt;Instagram&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>linux</category>
      <category>webdev</category>
      <category>git</category>
      <category>howto</category>
    </item>
    <item>
      <title>Add shortcut to VS Code in File Manager on Linux Mint</title>
      <dc:creator>Tom Benevides</dc:creator>
      <pubDate>Thu, 05 Dec 2019 02:20:52 +0000</pubDate>
      <link>https://dev.to/devatreides/add-shortcut-to-vs-code-in-file-manager-on-linux-mint-4hoh</link>
      <guid>https://dev.to/devatreides/add-shortcut-to-vs-code-in-file-manager-on-linux-mint-4hoh</guid>
      <description>&lt;p&gt;My programming job forces me to improve myself in many skills. One of them is managing multiples projects at the same time. As a web developer at a Brazilian university, I have to do many things to compensate for the low human and financial resources, very common at Brazilian government departments. So, I'm the guy who implements new services, maintain them and research/test new techs that maybe can help us.&lt;/p&gt;

&lt;p&gt;So, because of that, I usually have a few instances of my IDE opened for doing such things. Something very annoying (at least for me), is open a project with an IDE. You open your favorite IDE, then go to &lt;em&gt;open project&lt;/em&gt; and choose the project folder. Now, imagine doing that 3 or 4 times. Sometimes, I want some agility and this process is not that fast.&lt;/p&gt;

&lt;p&gt;Lucky me, I use Linux. So, I can do many things in that OS and customization is one of them (I don't know if I can customize Windows, I just say: I can do it on Linux). Anyway, the idea is very simple:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You just right-click on the project folder you want to open&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;select the "Open on IDE"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Happy life, easy-peasy.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tools and Steps
&lt;/h3&gt;

&lt;p&gt;For this "feature", I used an IDE, specifically the Visual Studio Code (aka VS Code) and the Linux Mint Cinnamon OS. I will not argue here about why I use VS Code + Mint and why YOU guys should use it because is not the purpose, now.&lt;/p&gt;

&lt;h5&gt;
  
  
  Now the big work! Pay attention!
&lt;/h5&gt;

&lt;p&gt;You just need to create a file at &lt;em&gt;~/.local/share/nemo/actions&lt;/em&gt; named &lt;strong&gt;open-vscode.nemo_actions&lt;/strong&gt; and paste this code on it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Nemo Action]

Name=Open on VS Code...

Comment=Open a Folder into Visual Studio Code

Exec=&amp;lt;open-vscode.sh %F&amp;gt;

Icon-Name=view-sidetree

Selection=Any

Extensions=dir;


Name[en]=Open on VS Code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This little piece of code is telling us: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;[Nemo Action] Name:&lt;/strong&gt; "Create a command named Open on VS Code" &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Exec:&lt;/strong&gt; "execute this script when someone uses the new command"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Icon:&lt;/strong&gt; "Show the command option with this icon"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Selection:&lt;/strong&gt; "Allow the command for this number of selected items"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Extensions:&lt;/strong&gt; "Allow the command for items with these extensions"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Name[x]:&lt;/strong&gt; "The message will appear like this in that language"  &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Besides that, you have to implement the script, who actually makes the magic. So, create at the same folder a file named &lt;strong&gt;open-vscode.sh&lt;/strong&gt; and paste this code on it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;dirname&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;pwd&lt;/span&gt; &lt;span class="nt"&gt;-P&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/&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;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="nv"&gt;$DIR&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; code &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code is even more simple: the first line gets the absolute path of your selected item and the second line flows into your item folder running the VS Code. Now, just run on terminal &lt;strong&gt;nemo -q&lt;/strong&gt; to reload the file manager and.. &lt;em&gt;Ta-da! pom-pom pom-pom&lt;/em&gt; \o/.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--61wosR2y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/hbw9ez4bzxj2gokenrjn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--61wosR2y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/hbw9ez4bzxj2gokenrjn.png" alt="vs Code - nemo option" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Oh! Don't forget to give execute permission to the script or none of this will work. &lt;/p&gt;

&lt;p&gt;So, that's it. You can add more commands (or actions as Nemo calls) just creating other .nemo_actions files as you wish. These customize commands will work only in your account once they're in your home folder. If you want to make these commands global on your Linux Mint, copy the .nemo_actions file to &lt;em&gt;/usr/share/nemo/actions&lt;/em&gt; and then reload the file manager.&lt;/p&gt;

&lt;p&gt;If you liked the post, react or comment on it. And don't forget to share with other people who might enjoy this tip. So .. See you soon!&lt;/p&gt;

</description>
      <category>linux</category>
      <category>tutorial</category>
      <category>webdev</category>
      <category>howto</category>
    </item>
  </channel>
</rss>
