I managed to get vim in the terminal using the system clipboard by using a version compiled with +clipboard and using set clipboard=unnamed
in .vimrc. But I wanted to go one further and have the last entry in my emacs-like kill-ring in bash go to the system clipboard too. So that when I hit Ctrl-k on the commandline I can Cmd-v that text into my text editor (or anywhere). Turns out this is pretty tricky.
The best solution I have so far is courtesy of user3439894 on the Apple Stack Exchange. It requires me to use Ctrl-Shift-k to kill instead of Ctrl-k but otherwise does what I want pretty well. You can find the gory details at https://apple.stackexchange.com/a/336361/301884.
Just yesterday a better answer was added to my stack exchange question that makes it work exactly as I wished – https://apple.stackexchange.com/a/400244/301884