Skip to content

Instantly share code, notes, and snippets.

@fsalehpour
Last active September 17, 2019 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fsalehpour/e4aad2d12c160cb22cdb2e410c87203f to your computer and use it in GitHub Desktop.
Save fsalehpour/e4aad2d12c160cb22cdb2e410c87203f to your computer and use it in GitHub Desktop.
A zsh function that prints all the shell commands ran by the current user since the beginning of the today!
#!/usr/bin/env zsh
function today (){
if [[ 0 -eq $# ]]; then
lines=10
else
lines="$1"
fi
output=$(fc -lin -$lines)
filtered=$(echo $output | grep $(date "+%Y-%m-%d"))
filtered_lines="$(echo $filtered | wc -l)"
if [[ $lines -eq $filtered_lines ]]; then
lines=$(($lines * 2))
today $lines
else
echo $filtered
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment