Shell abbrs ftw
Shell abbreviations have become an essential part of my workflow, often taking priority over traditional aliases. The main reason? Abbreviations allow me to complete the full command directly in the shell, providing clarity without needing to remember what’s hidden behind an alias. They make the workflow more transparent and adaptable.
While aliases work well in some cases, abbreviations strike a better balance of flexibility and clarity. They’re particularly useful when paired with plugins like autopair.fish or zsh-autopair for Zsh. Combined with Fish’s excellent out-of-the-box autocompletion, this setup makes working in the shell smooth and intuitive.
For example, an abbreviation like (fish shell):
abbr gc --set-cursor=! 'git commit -m "!"'
not only expands the command inline but also places the cursor inside the double quotes, ready for the commit message. It even sets the double quotes for me, which is incredibly comfortable and saves time. This small but impactful feature reduces friction in repetitive tasks and makes command composition much faster.
abbr kex --set-cursor=! 'kubectl exec -it ! /bin/bash'
This lets me type kex, use tab completion to select the desired pod, and seamlessly enter an interactive shell inside the container. The integration of abbreviations with autocompletion feels natural and heavily streamlines tasks that would otherwise involve longer, error-prone typing.
This small but powerful feature streamlines tasks and removes unnecessary steps, making it incredibly efficient for frequent workflows.