DEV Community

Discussion on: My Favorite Bash Tips, Tricks, and Shortcuts

Collapse
 
suckup_de profile image
Lars Moelleken • Edited

Tip: if you add aliases you can add the original command as prefix, so that if you have auto-completion, you can remember your stuff. :)

e.g.: aliases
github.com/voku/dotfiles/blob/mast...

# show the biggest files in a folder first
alias du_overview='du -h | grep "^[0-9,]*[MG]" | sort -hr | less'
Enter fullscreen mode Exit fullscreen mode

e.g.: functions
github.com/voku/dotfiles/blob/mast...

# history_top_used: show your most used commands in your history
history_top_used()
{
  history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
yechielk profile image
Yechiel Kalmenson

Great idea!