Created
February 9, 2017 15:33
-
-
Save ebith/1072db2cccef3ffad2e012432eae4241 to your computer and use it in GitHub Desktop.
TwittperatorでURL付きツイートする時よしなにしてくれるやつ
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
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