Skip to content

Instantly share code, notes, and snippets.

@izawa
Created February 20, 2014 09:11
Show Gist options
  • Save izawa/9109720 to your computer and use it in GitHub Desktop.
Save izawa/9109720 to your computer and use it in GitHub Desktop.
t.co url -> regular url replacer function
;; t.co -> regular url replacer
(defun untco ()
(interactive)
(let ((tco (buffer-substring (region-beginning) (region-end))))
(setq resolv (replace-regexp-in-string "\n+$" "" (shell-command-to-string (format "curl -s -I %s |awk \'$1~/[lL]ocation/{print $2}\'" tco))))
(if (> (length resolv) 0)
(progn
(kill-region (region-beginning) (region-end))
(insert resolv)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment