Last active
September 17, 2019 17:41
-
-
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!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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