Are you familiar with huffman encoding? That’s where you pick shorter codes for more frequent letters. Morse code is the same way. Shorter characters are the ones you are most likely to use. [Matheus Richard] had the same idea for optimizing your workflow in the Linux shell. The idea is to measure what commands you use the most and make them shorter.
If you use zsh, it is easy to find out what commands you are using the most. If you use bash, [Matheus] helpfully offers a command to give you a similar result (the original post limits the list to the last entry which we are sure is a typo):
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
Once you know the commands you use the most, you can use your shell’s aliasing or scripts to shorten them up. For example, in [Matheus’] case, git was a very common command. This led to aliases:
alias gc="git commit --verbose" alias gp="git push" alias gprom="git pull --rebase origin main"
Not only does this save typing, but you lessen your chance for typos (git comit, for example). Another idea is to alias your common errors, for example setting an alias for git as gti.
Small things, but definitely time savers. Be sure to read the rest of the post, as there are a number of other optimization ideas. [Matheus] definitely has a thing for zsh, but there are many other shells out there. Some of them are even evolving towards more modern programming languages.
This articles is written by : Fady Askharoun Samy Askharoun
All Rights Reserved to Amznusa www.amznusa.com
Why Amznusa?
AMZNUSA is a dynamic website that focuses on three primary categories: Technology, e-commerce and cryptocurrency news. It provides users with the latest updates and insights into online retail trends and the rapidly evolving world of digital currencies, helping visitors stay informed about both markets.