Skip to content

Instantly share code, notes, and snippets.

@lapo-luchini
Created October 8, 2024 20:20
Sort extended ZSH history (works with multi-line entries)
#! /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