Single key shortcut to copy Safari URL to clipboard

I use Vimium C in Chrome for single key shortcuts similar to those that were originally introduced by Opera when it was at its peak many years ago.

a - prev tab
s - next tab
z - go back
x - go forward
c - close tab
t - new tab
v - view source
u - copy url

I am able to set most of these using Vimari in Safari but it is not currently possible to set one for copying the page URL (GitHub topic).

Does anyone have a workaround?

I am aware of ⌘L followed by ⌘C but I prefer either pressing just u or yy.

You could hack your way around it with Keyboard Maestro, but then that key you’ve set will be lost even when you’re in Vimari insert mode (since there’s no way to tell KM the difference between these modes).

Set up ⌘+U shortcut using the Shortcuts app. That’ll do for now.

1 Like

Well… there’s no really easy or direct way.

I can think of a potential solution, but it’s neither elegant nor foolproof. It’s also untested, because it’s late and I’m tired, but if you need help with this and can’t figure out how to try it, hit me another time and remind me.

The logic is something like this (in Keyboard Maestro):

  • Create a macro group that is only active in Safari
  • When you press u check to see if the menu Edit » Paste is enabled. If yes, then you are probably in an edit field and want to insert the letter u so have Keyboard Maestro enter the letter u
  • ELSE - do cmd+L and then cmd+C

The left image below shows when the regular letter u should be entered.
The right shows when the other action should happen:

Basically, when you’re just reading a web page, there’s no way to ‘paste’ anything, so it’s safe to assume that you want to copy the URL. But if you can paste something, then it means that you are probably somewhere where you are typing something.

Keyboard Maestro can also take yy as a trigger to run a macro in Safari, as long as you are sure that you’ll never want to type yy.