<?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: João Pedro Gonçalves Rocha Ribeiro</title>
    <description>The latest articles on DEV Community by João Pedro Gonçalves Rocha Ribeiro (@uxxxjp).</description>
    <link>https://dev.to/uxxxjp</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%2F1713094%2F2c758ba5-1572-453f-ad37-87fef4bfdd42.png</url>
      <title>DEV Community: João Pedro Gonçalves Rocha Ribeiro</title>
      <link>https://dev.to/uxxxjp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/uxxxjp"/>
    <language>en</language>
    <item>
      <title>🐧👾💅 The First Bash Prompt Customization I NEED to Do - Linux</title>
      <dc:creator>João Pedro Gonçalves Rocha Ribeiro</dc:creator>
      <pubDate>Thu, 11 Jul 2024 03:25:49 +0000</pubDate>
      <link>https://dev.to/uxxxjp/the-first-bash-prompt-customization-i-need-to-do-linux-2e4p</link>
      <guid>https://dev.to/uxxxjp/the-first-bash-prompt-customization-i-need-to-do-linux-2e4p</guid>
      <description>&lt;p&gt;While I'm developing, the terminal prompt is one of the most frequently used tools in my workflow, so I like to make it look cool.&lt;/p&gt;

&lt;h2&gt;
  
  
  Virgin Ubuntu
&lt;/h2&gt;

&lt;p&gt;I'm using Mac to "run" Ubuntu through Multipass. The following command creates a new Ubuntu instance named cool-prompt and starts an interactive shell. The initial appearance is:  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhkdq317g1ch7ek3tzj7z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhkdq317g1ch7ek3tzj7z.png" alt="virgin appearance" width="554" height="146"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  PS1
&lt;/h2&gt;

&lt;p&gt;We need to change the value of a variable called PS1 in the .bashrc file.&lt;br&gt;&lt;br&gt;
PS1 stands for "Prompt String 1". It specifically defines the primary prompt that appears before each command when the shell is ready to accept input.&lt;br&gt;&lt;br&gt;
&lt;code&gt;.bashrc&lt;/code&gt; stands for "Bourne Again SHell Run Commands"; this file is a script that runs whenever the Bash shell is started.&lt;/p&gt;
&lt;h2&gt;
  
  
  Config for Default User
&lt;/h2&gt;

&lt;p&gt;The default user is the one you get out of the box, which in the image is ubuntu as shown previously.&lt;/p&gt;

&lt;p&gt;Open the .bashrc file and edit PS1. You can use vi since it comes with Ubuntu:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vi ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Navigate to the end of the file (use the 'G' shortcut in vi) and paste the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;parse_git_branch&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    git branch 2&amp;gt; /dev/null | &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s1"&gt;'/^[^*]/d'&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s1"&gt;'s/* \(.*\)/ (\1)/'&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="nv"&gt;PS1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'\[\033[01;32m\]@\u\[\033[00m\] \[\033[01;34m\]\W\[\033[00m\]\[\033[01;36m\]$(parse_git_branch)\[\033[00m\]\n$ '&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code will execute later at the end of the file and overwrite the value of PS1. If you know what you're doing and prefer, you can delete any previous manipulations of PS1.&lt;/p&gt;

&lt;p&gt;This shell script defines a function to retrieve the current Git branch of a directory if it's a Git repository. It then formats the prompt with different colors for the current user's name, the current folder, and the Git branch (if applicable). Finally, it inserts a newline and $ to indicate the start of commands.&lt;/p&gt;

&lt;p&gt;After editing the .bashrc file, every new shell session will use the new configuration. To apply the changes to the current shell prompt, use:&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="nb"&gt;source&lt;/span&gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After sourcing .bashrc, your prompt should look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2942e6513rq3vcm55c3o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2942e6513rq3vcm55c3o.png" alt="current folder" width="800" height="133"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a git repo:&lt;br&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu56rvbkl10a6rtg3xgdy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu56rvbkl10a6rtg3xgdy.png" alt="git repo dir" width="718" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Config for Root User
&lt;/h2&gt;

&lt;p&gt;Youre all happy with your new prompt, but some task forces you to use the root user. To your surprise(especially if you're a noob like me), your prompt get uglier than ever.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7fmg6r5rbmn3m0ytk13t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7fmg6r5rbmn3m0ytk13t.png" alt="ugly bash prompt" width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ok! Don't worry. Open &lt;code&gt;.bashrc&lt;/code&gt; again, go to the end of the file, paste the same code from the previous section. This ensures that every time a new root session is initialized, your prompt configuration will be applied. Remember to source .bashrc in the current prompt if you want the changes to take effect immediately.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6r4g9d4mjvfuho2aptjv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6r4g9d4mjvfuho2aptjv.png" alt="Root ps1 config" width="800" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And we're done !🥳!&lt;/p&gt;

&lt;h2&gt;
  
  
  There is more
&lt;/h2&gt;

&lt;p&gt;There are much more configs possible in the shell prompt. Just to give a general idea the following link show some of the  special characters that can be used in prompt variables &lt;a href="https://www.gnu.org/software/bash/manual/html_node/Controlling-the-Prompt.html" rel="noopener noreferrer"&gt;https://www.gnu.org/software/bash/manual/html_node/Controlling-the-Prompt.html&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Thanks for reading
&lt;/h3&gt;

</description>
      <category>linux</category>
      <category>ubuntu</category>
      <category>cli</category>
      <category>dx</category>
    </item>
    <item>
      <title>How to deploy React App to GitHub Pages - Caveman Style 🌋 🔥🦴</title>
      <dc:creator>João Pedro Gonçalves Rocha Ribeiro</dc:creator>
      <pubDate>Mon, 01 Jul 2024 19:10:10 +0000</pubDate>
      <link>https://dev.to/uxxxjp/how-to-deploy-react-app-to-github-pages-caveman-style-2alh</link>
      <guid>https://dev.to/uxxxjp/how-to-deploy-react-app-to-github-pages-caveman-style-2alh</guid>
      <description>&lt;p&gt;Like a good caveman you have to do everything by hand and with as little automation as possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create the New Repo
&lt;/h2&gt;

&lt;p&gt;Create the repo on your GitHub Account&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjchhkd2w19vist0a1hoy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjchhkd2w19vist0a1hoy.png" alt="Image description" width="198" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a public repo named &lt;code&gt;&amp;lt;user-name.github.io&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgjdrpmjnt7yb3od0wjs3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgjdrpmjnt7yb3od0wjs3.png" alt="Image description" width="615" height="266"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Configure the GitHub Pages to Deploy From Branch
&lt;/h2&gt;

&lt;p&gt;Go to Settings tab:  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyd01uok77m46gysoe9pc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyd01uok77m46gysoe9pc.png" alt="Image description" width="728" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the left side menu choose Pages&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fln8x0coygdoqb58y83j2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fln8x0coygdoqb58y83j2.png" alt="Image description" width="436" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the building and deploy options choose Deploy from branch and select the branch you want to use.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe0qtm3xtpqq68sw7k2dh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe0qtm3xtpqq68sw7k2dh.png" alt="Image description" width="276" height="309"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now your have configured everything by hand to make your GitHub Pages Site able to receive files for deploy.&lt;/p&gt;
&lt;h2&gt;
  
  
  Create a your React App Static Website
&lt;/h2&gt;

&lt;p&gt;You my have it finished already and don't need to create. I used &lt;code&gt;vite&lt;/code&gt; and &lt;code&gt;pnpm&lt;/code&gt; and choose a typescript template. So it would look like:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pnpm create vite&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqlmda8ltcb5b50f4e43v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqlmda8ltcb5b50f4e43v.png" alt="Image description" width="800" height="254"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fezwrr9hki981odm8jxnr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fezwrr9hki981odm8jxnr.png" alt="Image description" width="534" height="248"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, do your thing react and push it to GitHub.&lt;br&gt;&lt;br&gt;
It may involve:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"react app first commit"&lt;/span&gt;
git remote add origin git@github.com:&amp;lt;user&amp;gt;/&amp;lt;repo&amp;gt;.git
git push &lt;span class="nt"&gt;-u&lt;/span&gt; origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Be the Caveman
&lt;/h2&gt;

&lt;p&gt;In the configured branch you only need the files generated by React's build, and your App will be live at https://.github.io/. The root of your branch should look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqckgm0h3t8cvgsdw0gee.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqckgm0h3t8cvgsdw0gee.png" alt="Image description" width="731" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To generate the files use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or whatever is your package manager.&lt;/p&gt;

&lt;p&gt;Then delete all files except the &lt;em&gt;dist&lt;/em&gt; folder(be careful if you don't have a backup in another branch you can lose everything), copy &lt;em&gt;dist&lt;/em&gt; folder's content to the root folder and delete &lt;em&gt;dist&lt;/em&gt; folder. You can do it by hand or use a script since we're not going to remain caveman forever, and I want to start automating things in the next posts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-mindepth&lt;/span&gt; 1 &lt;span class="nt"&gt;-maxdepth&lt;/span&gt; 1 &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s1"&gt;'dist'&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s1"&gt;'.git'&lt;/span&gt; &lt;span class="nt"&gt;-exec&lt;/span&gt; &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt; +
&lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; dist/&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; dist
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Commit and push to the configured branch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Not Caveman Forever
&lt;/h2&gt;

&lt;p&gt;The process I just showed is error prone and cumbersome. In another post I will discuss how I automated it, for those impatient here is the code of the automation &lt;a href="https://github.com/uxjp/uxjp.github.io/pull/5/files"&gt;https://github.com/uxjp/uxjp.github.io/pull/5/files&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>github</category>
      <category>react</category>
      <category>staticwebapps</category>
    </item>
  </channel>
</rss>
