Created
October 8, 2024 20:20
-
-
Save lapo-luchini/3b5e2b5d42326393a6ba5ba6b5216d08 to your computer and use it in GitHub Desktop.
Sort extended ZSH history (works with multi-line entries)
This file contains 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 node | |
const fs = require('fs'); | |
const lines = fs.readFileSync(process.argv[2], 'utf8').split(/(?<=[^\\])\n/); | |
lines.sort((a, b) => a.split(/:/)[1] - b.split(/:/)[1]); | |
fs.writeFileSync(process.argv[2], lines.join('\n'), 'utf8'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment