<?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: Piotr Usewicz</title>
    <description>The latest articles on DEV Community by Piotr Usewicz (@pusewicz).</description>
    <link>https://dev.to/pusewicz</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%2F73231%2Fe6a2a12a-6d09-4718-97f1-85949d7e1c56.png</url>
      <title>DEV Community: Piotr Usewicz</title>
      <link>https://dev.to/pusewicz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pusewicz"/>
    <language>en</language>
    <item>
      <title>Fish abbreviations–what are they and how to configure them?</title>
      <dc:creator>Piotr Usewicz</dc:creator>
      <pubDate>Fri, 16 Dec 2022 04:27:00 +0000</pubDate>
      <link>https://dev.to/pusewicz/fish-abbreviations-what-are-they-and-how-to-configure-them-5el4</link>
      <guid>https://dev.to/pusewicz/fish-abbreviations-what-are-they-and-how-to-configure-them-5el4</guid>
      <description>&lt;p&gt;Fish &lt;a href="https://fishshell.com/docs/current/cmds/abbr.html" rel="noopener noreferrer"&gt;abbreviations&lt;/a&gt; are a fantastic way to configure what is commonly known as aliases for your day-to-day use.&lt;/p&gt;

&lt;p&gt;The difference between an alias and an abbreviation is that it expands to the entire command whenever the abbreviation gets triggered. Traditionally, aliases are shown as they are typed in the shell’s history.&lt;/p&gt;

&lt;p&gt;The expansion is an excellent benefit of using abbreviations. One can always see the actual command behind the shorthand version. This is both useful for remembering the actual command and significant when sharing commands with others (such as in screenshots of the terminal), as they do not have to decode the aliases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s configure some abbreviations
&lt;/h2&gt;

&lt;p&gt;We will edit the &lt;code&gt;~/.config/fish/conf.d/abbreviations.fish&lt;/code&gt; file. Any file in the &lt;code&gt;~/.config/fish/conf.d&lt;/code&gt; directory will be &lt;a href="https://fishshell.com/docs/current/#configuration" rel="noopener noreferrer"&gt;automatically loaded&lt;/a&gt; in a standard &lt;code&gt;fish&lt;/code&gt; setup. A separate file for abbreviations makes it easier to find the right place to configure them.&lt;/p&gt;

&lt;p&gt;Below is the content of my file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;abbr be "bundle exec"

abbr ghb "gh browse" # Open the current repository on GitHub
abbr ghc "hub compare" # Open the diff of the branch on GitHub

abbr bu "brew upgrade"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, the syntax is similar to the &lt;a href="https://fishshell.com/docs/current/cmds/alias.html" rel="noopener noreferrer"&gt;alias&lt;/a&gt;. We use the &lt;code&gt;abbr&lt;/code&gt; command, followed by the abbreviation we’d like to use. Finally, the actual command it should expand to.&lt;/p&gt;

&lt;p&gt;To use the configured abbreviation, we need to type it, and either press Enter to expand and execute, or Space to only expand it, allowing us to add any arguments to the command.&lt;/p&gt;

&lt;p&gt;Here’s a demo:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://asciinema.org/a/wOt70n7TKym3ijKtFhwUUTSvd" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fasciinema.org%2Fa%2FwOt70n7TKym3ijKtFhwUUTSvd.svg" alt="asciicast" width="859" height="578"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Abbreviations add another touch of clarity to your own workflow. Switching from using aliases is trivial. To me, they are superior and a clear improvement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus points
&lt;/h2&gt;

&lt;p&gt;I’ve found &lt;a href="https://github.com/lewisacidic/fish-git-abbr" rel="noopener noreferrer"&gt;&lt;code&gt;fish-git-abbr&lt;/code&gt;&lt;/a&gt; plugin to be a fantastic collection of predefined abbreviations for &lt;code&gt;git&lt;/code&gt; usage. It’s got everything you might need when working with &lt;code&gt;git&lt;/code&gt; and save some keystrokes. I have also learned some new &lt;code&gt;git&lt;/code&gt; arguments!&lt;/p&gt;

</description>
      <category>fish</category>
    </item>
  </channel>
</rss>
