Quick Tip – Copying From Vim

This issue drove me insane. The answer was crazy simple so I figured I’d throw it out there.

I found that I could copy and paste anywhere in X without an issue (this uses the clipboard buffer). I could also select text and middle click to paste without issue (this uses the primary buffer. I could also select and paste with the mouse in URXVT. Within Vim, I could also copy by selecting and paste (when in insert mode) with a middle click. What I couldn’t do was select text in Vim and middle click to paste it anywhere else.

Further, I could confirm that the data wasn’t hitting the primary buffer upon selection using xsel -op to dump the primary buffer.

After a good while of searching (which came after more time than should have been spent diagnosing the exact issue) I found this thread, which described my issue and the solution.

The answer is that the mouse=a directive in my vimrc that makes visual mode work with the mouse is also keeping it from selecting text in the way that’s needed to drop it into the primary buffer (to copy it). Disabling this setting fixes the copy issue, but also turns off visual mode with the mouse, which I’d like to keep.

The workaround was to hold shift while selecting text I want to copy, which keeps it from entering visual mode and allows the copy to happen.

Cheers!

Startup script for i3 with Conditional Execution

I’ve been using the i3 window manager for roughly a couple of years now and have enjoyed playing with all the ways I’ve found to extend it through startup scripts, keybindings, etc. This little hack for enabling or disabling the launch of a group of applications at login is one of my favorites and I thought I’d share.

I’ve got a script in my i3 configuration directory called launch.sh that fires up a number of persistent applications and launches things I normally use.

The first thing it does is load a saved layout and launch terminals with htop, dmesg –follow, and tail -f /var/log/syslog . I use this as a general system monitor workspace, a dedicated place I can go to see what’s happening on my system.

Next, it switches to a workspace I use as a dedicated terminal and launches urxvt, then switches to the workspace I use for my browser, switches the layout to tabbed, then launches my browser.

Then it loads up the scratchpad text app I use (Fromscratch), udiskie for managing removable media, the mpd daemon, and after some delay to make sure everything else is finished loading, dropbox.

I’ve been happy with this arrangement, but really wanted to find a way to keep it from launching some of those items on startup in case I wanted to do something more system intensive and didn’t need those things right away or want to do some kind of benchmarking and want fewer things tying up RAM.

Continue reading “Startup script for i3 with Conditional Execution”