<?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: mlevesquedion</title>
    <description>The latest articles on DEV Community by mlevesquedion (@mlevesquedion).</description>
    <link>https://dev.to/mlevesquedion</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%2F97670%2Fba643ac6-b13d-47bb-bf62-8f02f09dc5f7.png</url>
      <title>DEV Community: mlevesquedion</title>
      <link>https://dev.to/mlevesquedion</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mlevesquedion"/>
    <language>en</language>
    <item>
      <title>My most important bash script</title>
      <dc:creator>mlevesquedion</dc:creator>
      <pubDate>Fri, 15 May 2020 23:46:07 +0000</pubDate>
      <link>https://dev.to/mlevesquedion/my-most-important-bash-script-5f6k</link>
      <guid>https://dev.to/mlevesquedion/my-most-important-bash-script-5f6k</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;If you want to do something, make it easy to do.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Applying this principle has allowed me to increase my productivity over time while protecting me from drudgery. Since I spend a lot of time in terminals, a simple example of this is defining appropriate aliases for commands I use a lot, so I don't need to type so much. Sometimes though, an alias doesn't cut it, and I need to write a small script.&lt;/p&gt;

&lt;p&gt;Historically, I would cd into a directory on my path, open up a file, write the shebang line, write the script, save it, make it executable, test it, and go back to whatever I was doing. However, since I was always doing those same steps, it made sense to write a script to help me write scripts faster. Here it is :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BIN_PATH="$HOME/bin/"
SCRIPT_NAME="$1"
SCRIPT_PATH="$BIN_PATH$SCRIPT_NAME"

if [ ! -s "$SCRIPT_PATH" ]; then
    echo "#!/bin/bash
" &amp;gt; "$SCRIPT_PATH"
    chmod u+x "$SCRIPT_PATH"
fi

vim "+${2-2}" "$SCRIPT_PATH"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I call it &lt;code&gt;scr&lt;/code&gt;, as in &lt;code&gt;script&lt;/code&gt;. Say I want to write a new script called foo. All I have to do is type &lt;code&gt;scr foo&lt;/code&gt; in a terminal, write the body of the script, save, and I'm done. The next time I want to edit the script, I once again type &lt;code&gt;scr foo&lt;/code&gt;, do whatever changes I need to do, save, and I'm done. Since this significantly decreases the effort needed to write scripts, it has allowed me to write more scripts to take care of a variety of tasks I perform often.&lt;/p&gt;

&lt;p&gt;I hope this small script, or even the philosophy that inspired it, can be of some use to you.&lt;/p&gt;

</description>
      <category>bash</category>
      <category>scripting</category>
      <category>linux</category>
      <category>productivity</category>
    </item>
    <item>
      <title>The most important alias</title>
      <dc:creator>mlevesquedion</dc:creator>
      <pubDate>Fri, 25 Oct 2019 01:27:25 +0000</pubDate>
      <link>https://dev.to/mlevesquedion/the-most-important-alias-2m36</link>
      <guid>https://dev.to/mlevesquedion/the-most-important-alias-2m36</guid>
      <description>&lt;p&gt;You may have heard of shell aliases. In short, &lt;code&gt;alias&lt;/code&gt; is a shell command that defines a substitution, e.g. with &lt;code&gt;alias clip='xclip -selection clipboard'&lt;/code&gt; you can type &lt;code&gt;clip&lt;/code&gt; in a command and it will be replaced by the part on the right.&lt;/p&gt;

&lt;p&gt;I believe aliases are key to a productive and enjoyable command line experience. They are cheap to create and maintain, and they save you a lot of typing.&lt;/p&gt;

&lt;p&gt;To me, one alias matters more than any other: &lt;code&gt;alias zc='vim ~/.zshrc'&lt;/code&gt;. (feel free to replace &lt;code&gt;vim&lt;/code&gt; with your favorite &lt;code&gt;$EDITOR&lt;/code&gt;, and &lt;code&gt;.zshrc&lt;/code&gt; with your favorite &lt;code&gt;$SHELL&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;With this alias, you can improve your development workflow in a snap. Just entered the same command three times in the last five minutes? Open a terminal, enter "zc", alias it, and enjoy.&lt;/p&gt;




&lt;p&gt;The actual alias I use is &lt;code&gt;vim -n $ZSHRC; source $ZSHRC&lt;/code&gt;. That way my changes are applied immediately upon exiting the file.&lt;/p&gt;

&lt;p&gt;For more, see my &lt;a href="https://github.com/mlevesquedion/dotfiles"&gt;dotfiles&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>shell</category>
      <category>productivity</category>
      <category>customization</category>
    </item>
  </channel>
</rss>
