Stop Chrome From Mangling Your Clipboard

Many releases back, Chrome began to automatically change URLs that you copy from the location bar. In Chrome, if you see “” in your location bar and select and copy that, in your clipboard, Chrome changes it to “” This is a pain-in-the-ass if, say, you’re going to copy that into a terminal and intend to traceroute|ping|dig the host.

I can see how some users might find this behavior beneficial, but it’s unexpected and annoying for people who expect that what you copy is what will be pasted.

There were some janky Chrome extensions that tried to solve this, but I figured solving this in Alfred workflows would be a better solution. I made a simple workflow that provides an alternate paste command (command + shift + v) via Alfred and strips out the protocol, www. (if it is present), and the path contained in the URL. This is really just a one-line bash command:

echo -n '{query}' | awk '{gsub("https?://|https?://www\.|/.*","")}1'

You can download the Alfred workflow here, too.

Side note: don’t forget about the built-in paste feature in MacOS that strips formatting. That key combination is: command + option + shift + v. This is extremely useful when pasting something that contains formatting (font, size, etc) into an editor where you don’t want the source formatting.