Skip to content

Instantly share code, notes, and snippets.

@ebith
Created Feb 9, 2017
Embed
What would you like to do?
TwittperatorでURL付きツイートする時よしなにしてくれるやつ
javascript <<EOM
twtu = (title, url) => {
const args = commandline.command.split(/\s+/);
const text = args.slice(1, -1).join(' ');
const match = /^@\w{1,15}(#\d+)$/.exec(args[1]);
const r = 140 - 23 - text.length + (match ? match[1].length : 0);
if (title.length > r-7) {
title = title.slice(0, r-7) + '\u2026'
}
return `"${title}" - ${url}`;
}
EOM
abbrev -j .tu twtu(buffer.title, buffer.URL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment