Skip to content

Instantly share code, notes, and snippets.

@ebith
Created February 9, 2017 15:33
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 ebith/1072db2cccef3ffad2e012432eae4241 to your computer and use it in GitHub Desktop.
Save ebith/1072db2cccef3ffad2e012432eae4241 to your computer and use it in GitHub Desktop.
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