<?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: Rishit Pandey</title>
    <description>The latest articles on Forem by Rishit Pandey (@rishitpandey).</description>
    <link>https://forem.com/rishitpandey</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%2F254261%2F5c4637f7-f53d-4360-b6aa-e8f80e188389.jpeg</url>
      <title>Forem: Rishit Pandey</title>
      <link>https://forem.com/rishitpandey</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/rishitpandey"/>
    <language>en</language>
    <item>
      <title>Setting Up Neovim like VSCode</title>
      <dc:creator>Rishit Pandey</dc:creator>
      <pubDate>Sat, 23 Oct 2021 10:10:52 +0000</pubDate>
      <link>https://forem.com/rishitpandey/setting-up-neovim-like-vscode-j8h</link>
      <guid>https://forem.com/rishitpandey/setting-up-neovim-like-vscode-j8h</guid>
      <description>&lt;h2&gt;
  
  
  My own setup
&lt;/h2&gt;

&lt;p&gt;A lot of us use vscode for our day to day development work and we are used to its features. But for some of us vscode seems to be heavy on the resource usage and lags a little. So I switched to vim editor but when I started my development work, I was missing a lot of vscode features like auto-suggestions, completions, jumping to another file, etc and then I stumbled upon something that came from heaven.&lt;/p&gt;

&lt;p&gt;Believe me this can be done in vim (neovim) too. There are lots of vim plugins available for this and even neovim 0.5 supports this out of the box with little configuration needed with lua language.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we need
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;We need a plugin manager to install plugins for our vim editor&lt;/li&gt;
&lt;li&gt;We also need neovim instead of vim editor for our setup.&lt;/li&gt;
&lt;li&gt;And we need nodejs and npm installed on our system.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Plugin Manager: vim-plug
&lt;/h2&gt;

&lt;p&gt;The plugin manager that we will be using in our setup is &lt;code&gt;vim-plug&lt;/code&gt; which can be found &lt;a href="https://github.com/junegunn/vim-plug" rel="noopener noreferrer"&gt;here&lt;/a&gt;. What this plugin manager will do is that it will install various utilities and plugins that the vim community has created without any builds required by the user. Just add the plugin name to the vim config and it will install that plugin.&lt;br&gt;
Let's install vim plug now. As a neovim user, run&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

   sh &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s1"&gt;'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
       https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'&lt;/span&gt;



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

&lt;/div&gt;

&lt;p&gt;This will install the vim plug manager on your system. Now since you are using neovim, create a directory &lt;code&gt;nvim&lt;/code&gt; in your config folder which is &lt;code&gt;~/.config&lt;/code&gt; for UNIX-based systems, and then there create a file as &lt;code&gt;init.vim&lt;/code&gt;.&lt;br&gt;
The final structure looks like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

   ~/.config/nvim/init.vim


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

&lt;/div&gt;

&lt;p&gt;Now open &lt;code&gt;init.vim&lt;/code&gt; file and add these lines,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight viml"&gt;&lt;code&gt;

&lt;span class="k"&gt;call&lt;/span&gt; plug#begin&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'~/.vim/plugged'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;" leave some space in between&lt;/span&gt;

&lt;span class="k"&gt;call&lt;/span&gt; plug#end&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c"&gt;" we will add keybinds below this comment.&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;What these lines do? These lines call a function to enable the installed plugins whenever we open our neovim editor. Here we will add the plugins for usecases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Plugins
&lt;/h2&gt;

&lt;p&gt;As a former vscode user, I use a lot of vim plugins to make the experience better and to be honest it is okay to use a lot of plugins.&lt;/p&gt;

&lt;h3&gt;
  
  
  NerdTree
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To have a folder structure and to view or jump to different files while in the vim editor, We can use the plugin &lt;code&gt;nerdtree&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can install the plugin by adding,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight viml"&gt;&lt;code&gt;

   Plug &lt;span class="s1"&gt;'preservim/nerdtree'&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;This will give you a directory management panel on your left side.&lt;br&gt;
Now add below config and keybindings for nerdtree&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight viml"&gt;&lt;code&gt;

&lt;span class="c"&gt;"Changing default NERDTree arrows&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;g:NERDTreeDirArrowExpandable&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'▸'&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;g:NERDTreeDirArrowCollapsible&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'▾'&lt;/span&gt;

nnoremap &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;C&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="k"&gt;t&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;NERDTreeToggle&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;CR&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;The above lines change the arrow type when changing directories in nerdtree and the nnoremap keybind binds &lt;code&gt;Ctrl + t&lt;/code&gt; to open nerdtree.&lt;br&gt;
You can also look at the actions for the directory by pressing &lt;code&gt;m&lt;/code&gt; while you are on the nerdtree panel.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Completion
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;For the code completion I use coc vim completion plug. For this you need nodejs and npm installed to get the language packs with which you will get suggestions and code completion.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight viml"&gt;&lt;code&gt;

Plug &lt;span class="s1"&gt;'neoclide/coc.nvim'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'branch'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'release'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Add this between those two plug lines that we added from the above section.&lt;br&gt;
Then add these keybindings for working with coc,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight viml"&gt;&lt;code&gt;

nmap &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;silent&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;gd&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;Plug&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;coc&lt;span class="p"&gt;-&lt;/span&gt;definition&lt;span class="p"&gt;)&lt;/span&gt;
nmap &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;silent&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; gy &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;Plug&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;coc&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="p"&gt;-&lt;/span&gt;definition&lt;span class="p"&gt;)&lt;/span&gt;
nmap &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;silent&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;gr&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;Plug&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;coc&lt;span class="p"&gt;-&lt;/span&gt;references&lt;span class="p"&gt;)&lt;/span&gt;

nmap &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;silent&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;g&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;Plug&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;coc&lt;span class="p"&gt;-&lt;/span&gt;diagnostic&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="k"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
nmap &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;silent&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="k"&gt;g&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;Plug&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;coc&lt;span class="p"&gt;-&lt;/span&gt;diagnostic&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="k"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
nnoremap &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;silent&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;space&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;s &lt;span class="p"&gt;:&amp;lt;&lt;/span&gt;C&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="k"&gt;u&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;CocList &lt;span class="p"&gt;-&lt;/span&gt;I symbols&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;cr&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;

nnoremap &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;silent&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;space&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="k"&gt;d&lt;/span&gt; &lt;span class="p"&gt;:&amp;lt;&lt;/span&gt;C&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="k"&gt;u&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;CocList diagnostics&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;cr&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;

nmap &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;leader&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;Plug&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;coc&lt;span class="p"&gt;-&lt;/span&gt;codeaction&lt;span class="p"&gt;)&lt;/span&gt;

nmap &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;leader&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;rn &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;Plug&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;coc&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="nb"&gt;rename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Then to add the language packs for coc,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight viml"&gt;&lt;code&gt;

&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;g:coc_global_extensions&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="se"&gt;  \&lt;/span&gt; &lt;span class="s1"&gt;'coc-tsserver'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="se"&gt;  \&lt;/span&gt; &lt;span class="s1"&gt;'coc-json'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="se"&gt;  \&lt;/span&gt; &lt;span class="s1"&gt;'coc-css'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="se"&gt;  \&lt;/span&gt;  &lt;span class="s1"&gt;'coc-eslint'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="se"&gt;  \&lt;/span&gt;  &lt;span class="s1"&gt;'coc-prettier'&lt;/span&gt;
&lt;span class="se"&gt;  \&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;



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

&lt;/div&gt;

&lt;p&gt;These are some of the language packs that I use. You can go &lt;a href="https://github.com/neoclide/coc.nvim" rel="noopener noreferrer"&gt;here&lt;/a&gt; and can look for other language packs as well.&lt;/p&gt;

&lt;p&gt;Now in the same directory where we created &lt;code&gt;init.vim&lt;/code&gt;, create another file as &lt;code&gt;coc-settings.json&lt;/code&gt;. Then add the following,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"eslint.autoFixOnSave"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"eslint.filetypes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"javascript"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"javascriptreact"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"typescript"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"typescriptreact"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"coc.preferences.formatOnSaveFiletypes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"javascript"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"javascriptreact"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"typescript"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"typescriptreact"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"tsserver.formatOnType"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"coc.preferences.formatOnType"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;Note that these settings are only for the language packs that I use so if you are using the same packs with additional packages on top of it, you can have these configs otherwise it might create problems or give you an error when you open vim.&lt;/p&gt;

&lt;h3&gt;
  
  
  Colorscheme
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fpineapplegiant%2Fspaceduck-terminal%2Fmain%2Fimg%2Fscreenshot.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fpineapplegiant%2Fspaceduck-terminal%2Fmain%2Fimg%2Fscreenshot.png" alt="spaceduck"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the color scheme, I use &lt;a href="https://github.com/pineapplegiant/spaceduck" rel="noopener noreferrer"&gt;spaceduck&lt;/a&gt;, which is a blue coloured theme. To install this, add &lt;code&gt;Plug pineapplegiant/spaceduck', { 'branch': 'main' }&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And then add these lines below the plug function,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight viml"&gt;&lt;code&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'+termguicolors'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;let&lt;/span&gt; &amp;amp;&lt;span class="nb"&gt;t_8f&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"\&amp;lt;Esc&amp;gt;[38;2;%lu;%lu;%lum"&lt;/span&gt;
      &lt;span class="k"&gt;let&lt;/span&gt; &amp;amp;&lt;span class="nb"&gt;t_8b&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"\&amp;lt;Esc&amp;gt;[48;2;%lu;%lu;%lum"&lt;/span&gt;
      &lt;span class="k"&gt;set&lt;/span&gt; &lt;span class="nb"&gt;termguicolors&lt;/span&gt;
    &lt;span class="k"&gt;endif&lt;/span&gt;

   &lt;span class="k"&gt;colorscheme&lt;/span&gt; spaceduck



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

&lt;/div&gt;

&lt;p&gt;For more details, you can look here,&lt;br&gt;
&lt;a href="https://github.com/genzyy/suckless-builds/blob/dotfiles/config/nvim/init.vim" rel="noopener noreferrer"&gt;dotfiles&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thanks for reading and let me know if I can help you!&lt;/p&gt;

</description>
      <category>vim</category>
      <category>javascript</category>
      <category>programming</category>
      <category>opensource</category>
    </item>
    <item>
      <title>My Linux Fish Shell Workflow</title>
      <dc:creator>Rishit Pandey</dc:creator>
      <pubDate>Mon, 18 Oct 2021 10:27:31 +0000</pubDate>
      <link>https://forem.com/rishitpandey/my-linux-fish-shell-workflow-28lk</link>
      <guid>https://forem.com/rishitpandey/my-linux-fish-shell-workflow-28lk</guid>
      <description>&lt;p&gt;Hey Everyone!, I will be sharing my fish shell workflow on linux and how to set it up for your productivity boost.&lt;br&gt;
Let's get started!&lt;/p&gt;
&lt;h2&gt;
  
  
  A little about fish shell
&lt;/h2&gt;

&lt;p&gt;So you know about bash and zsh and how they work right? The fish shell is not like those shells. I mean they kinda have similarities but they do differ very much. ZSH can execute bash commands in a native as bash does but fish shell requires some editing to it specially when it comes to setting variables and exporting paths.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frbppfyn4krqxrxvp9b85.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frbppfyn4krqxrxvp9b85.png" alt="Fish Shell Workflow"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What's my workflow?
&lt;/h2&gt;

&lt;p&gt;I usually work on the terminals only and for that I frequent switch between different directories, editing them in vim (I use neovim), etc. So for me having a built-in autocompletion for shell with syntax highlighting and is a plus point.&lt;br&gt;
With that I also use &lt;a href="https://github.com/jethrokuan/z" rel="noopener noreferrer"&gt;this&lt;/a&gt;. This is a fish shell tool for jumping different directories with two word command.&lt;br&gt;
For example, I have a very nested directory that I want to visit and from there I need to go to another nested directory and let's name the first directory as &lt;code&gt;portfolio&lt;/code&gt; and &lt;code&gt;my terminal config&lt;/code&gt;. Now for that I use the &lt;code&gt;z&lt;/code&gt; tool and using the z tool I can create aliases for that directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;z portfolio
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can create the alias for that directory by going to that directory and then run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;z &amp;lt;short-name-of-that-directory&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now go back to your home directory and then run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;z &amp;lt;name-of-that-directory&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and whoosh! you are straight into that directory.&lt;/p&gt;

&lt;p&gt;Now I know some of you will say that we can create aliases in the shell itself but for that you have to go to its config file and then add that alias and the source the config file for every directory. Z tool helps to create aliases on the fly.&lt;/p&gt;

&lt;p&gt;For the fish prompt, I use starship cross-platform shell prompt. Its very minimal and easy to use with all the information you need for the directory is being displayed on your terminal in a very minimal way.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkox1c5pdjfb2q6xiyo0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkox1c5pdjfb2q6xiyo0g.png" alt="Fish Shell Workflow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to set it up?
&lt;/h2&gt;

&lt;p&gt;So first we will install fish shell.&lt;br&gt;
For mac users,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;fish
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For linux user, (chad users)&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;sudo &lt;/span&gt;pacman &lt;span class="nt"&gt;-S&lt;/span&gt; fish
&lt;span class="nb"&gt;sudo &lt;/span&gt;dnf &lt;span class="nb"&gt;install &lt;/span&gt;fish
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;fish
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the shell is installed, we will change the default shell for the user,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chsh &lt;span class="nt"&gt;-S&lt;/span&gt; /usr/bin/fish
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you just want to try out the fish shell, you can enter into fish shell just by running &lt;code&gt;fish&lt;/code&gt; in your terminal.&lt;/p&gt;

&lt;p&gt;Then we need to install a package manager for fish shell. The name is &lt;code&gt;fisher&lt;/code&gt;. &lt;a href="https://github.com/jorgebucaran/fisher" rel="noopener noreferrer"&gt;Fisher&lt;/a&gt; is a package manager for fish shell and is very fast.&lt;br&gt;
Install fisher by running,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-sL&lt;/span&gt; https://git.io/fisher | &lt;span class="nb"&gt;source&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; fisher &lt;span class="nb"&gt;install &lt;/span&gt;jorgebucaran/fisher
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the package manager is installed we can move on to installing and customizing the shell.&lt;/p&gt;

&lt;h2&gt;
  
  
  Add tools and Customize your shell!
&lt;/h2&gt;

&lt;p&gt;First we will install z tool. Using fisher we can run,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fisher &lt;span class="nb"&gt;install &lt;/span&gt;jethrokuan/z
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can create aliases for your directories and jump across them.&lt;/p&gt;

&lt;p&gt;For the prompt, I use &lt;a href="https://starship.rs/" rel="noopener noreferrer"&gt;Starship Prompt&lt;/a&gt;. For installing this I had some problem while running the below command in fish so I went to bash shell and executed the command and it installed the prompt successfully.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sh &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://starship.rs/install.sh&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problem I faced was because of the different syntax that fish uses in contrast of what bash and zsh use.&lt;/p&gt;

&lt;p&gt;Now you can also customize the prompt itself using a config file. I have my config &lt;a href="https://github.com/genzyy/dotfiles-v2/blob/main/config/starship.toml" rel="noopener noreferrer"&gt;here&lt;/a&gt; or you can read the starship docs &lt;a href="https://starship.rs/config/#prompt" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thats it! Enjoy with your new terminal friend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Extras
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You can also use tide which is powerlevel10k for fish and is much more customizable too.&lt;/li&gt;
&lt;li&gt;Also for icon support in the terminal while displaying directories, you can visit &lt;a href="https://github.com/jszczerbinsky/ptSh" rel="noopener noreferrer"&gt;ptSh&lt;/a&gt; and exa.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks for taking time to read and I appreciate your interest in my blog. This is my first blog so feel free to point out the mistakes and I will surely learn from them!&lt;/p&gt;

</description>
      <category>linux</category>
      <category>fishshell</category>
    </item>
  </channel>
</rss>
