Skip to content

Instantly share code, notes, and snippets.

@alejo4373
Created March 10, 2021 17:54
Show Gist options
  • Save alejo4373/51577d53c91a4921841276beec979769 to your computer and use it in GitHub Desktop.
Save alejo4373/51577d53c91a4921841276beec979769 to your computer and use it in GitHub Desktop.
Program to read your zsh history and output the 10 most common commands in it
cat ~/.zsh_history | # Read file
awk 'BEGIN { FS="[; ]" } { print $3}' | # Split file in fiels separated by a ; or a space and print the 3rd field
sort | # Sort each line lexicographically
uniq -c | # Count number of times a line occurs
sort -n -r | # Sort numerically and in reverse order
head # print the head of the output (first 10 lines)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment