Skip to content

Instantly share code, notes, and snippets.

@hogashi
Last active March 30, 2021 14:21
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 hogashi/794e903a849128fda89b069d52707e50 to your computer and use it in GitHub Desktop.
Save hogashi/794e903a849128fda89b069d52707e50 to your computer and use it in GitHub Desktop.
cat ~/.bash_history | \
tr -d '\r' | \
perl -pe '
chomp;
s/\\/\\\\/g;
s/"/\\"/g;
$_ = qq({\n "length": ) . length($_) . qq(,\n "command": ") . $_ . qq("\n}, );
' | \
perl -pe 's/, $//' | \
awk '
BEGIN { print "[" }
{ print " " $0 }
END { print "]"}
' > command-length.json
[
{
"length": 62,
"command": "git branch -d $(git branch -vv | grep gone | awk '{print $1}')"
}, {
"length": 79,
"command": "git branch -d $(git branch -vv | grep gone | awk '{ print $1 }' | tr '\\n' ' ')"
}, {
"length": 104,
"command": "git branch -d $(git branch -vv | grep -v 'origin/' | git branch -vv | awk '{ print $1 }' | tr '\\n' ' ')"
}, {
"length": 72,
"command": "git branch -d $(git branch -vv | grep -v 'origin/' | awk '{ print $1 }')"
}, {
"length": 69,
"command": "git branch -d $(git branch -vv | grep ': gone]' | awk '{ print $1 }')"
}, {
"length": 79,
"command": "git branch -D $(git branch -vv | grep gone | awk '{ print $1 }' | tr '\\n' ' ')"
}, {
"length": 79,
"command": "gir branch -d $(git branch -vv | grep gone | awk '{ print $1 }' | tr '\\n' ' ')"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment