Fixing Word Navigation in ZSH

Moving to zsh from bash has been a great quality of life improvement. However, there is one thing that has driven me nuts that I have not been able to figure out: customizing the word boundary definition.

I’m using zsh 5.9 and have a lot of plugins.

forward-word ,backward-word , and the kill variants were the main widgets that I use. I used bindkey to determine these functions. After some investigation, it seems like these widgets are controlled via zstyle ':zle:*' configuration. You can dump configuration via zstyle -L You can determine what underlying zsh function is used by a widget via zle -lL. If you want to view the source of a widget function use which After some digging, I found select-word-style which seemed to be what I was looking for, but didn’t work. After some grepping around I discovered word-style which solved the issue for me if I set it to unspecified. Based on the documentation, I shouldn’t need to do this, but this is what worked for me. I looked into the autocomplete, syntax highlighter, and substring history plugins but removing them did not fix the issue.

Here’s my final configuration which fixed the issue for me:

WORDCHARS='*?_-.[]~=&;!#$%^(){}<>/ '$'\n' autoload -Uz select-word-style select-word-style normal zstyle ':zle:*' word-style unspecified

Continue Reading

Using HTTPS Locally: Pow, SSL, Rails, and Apache

Using HTTPS local development or testing environments is a hassle. A common practice is to disable SSL in development, but I’ve had too many cases of minor bugs creeping in when routing works differently between environments. I also don’t like manually having to let my browsers know that a self-signed certificate is valid.

Here’s the configuration that I use to easily add https support on my development machine to any application served—or proxied—through port 80.

Pow

I use Pow as my development rails server. However, because I often work with other languages as well, I run Apache (you could just as easily use nginx) and reverse proxy Rails application requests to Pow.

To do this, you’ll need Pow to bind to a port that is not port 80. Here’s how to configure Pow to use port 88.

Apache

I use nginx in production environments, but I’ve been using Apache on my local development machines for years and just haven’t gotten around to changing my dotfiles to use nginx. You could just as easily use nginx here.

In any case, here’s what I was looking to achieve in my apache config:

Throw error logs in ~/Sites/logs Support vhosts + xip.io domains Access WordPress sites using site-name.wp.dev Access Rails applications using site-name.dev. These requests need to reverse proxy to pow on port 88. Support proxying *.test domains to a customized port. Having a *.test domain allows you to run SSL-enabled integration tests for a multi-domain Rails application against the rspec-run rails server. Checkout my series on rails testing for more details on why this is important.

I was able to get all of this working with a single file thrown in /etc/apache2/other.

Rails: Tunnelss to the Rescue

Tunnelss is a little gem that brings it all together. It looks at your pow config, generates self-signed certificates for those domains, and adds that certificate to your keychain so your browsers accept the self-signed certificate. Brilliant.

The only downside here is you must keep tunnelss running in the background. Right now, the project doesn’t have a launchd plist available. So, for now, you have to start the application manually on each system restart.

Continue Reading

Rails & Yosemite: Resolving libv8 and therubyracer Installation Problems

As a developer, upgrading to a new OS is always a task, especially when it comes to rails dependencies (surprisingly, Cocoa projects didn’t have as much of an issue with Yosemite).

I always wipe my machine and start fresh. This introduces a new class of problems, some of which I was able to mitigate this time around with mackup (a preference backup and restoration tool) and some upgrades to my dotfiles.

I customize bundler to work in parallel, store all gems for a given project in the vendor/ directory for that project, and to not use shared gems at all.

LibV8 Compilation Issues

I ran into this error when bundler tried to install libv8 on Yosemite:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

I found a similar problem on StackOverflow, but my situation was a bit different because of my use of disable-shared-gems

if ! bundle show therubyracer; then bundle config build.libv8 --with-system-v8 gem install --install-dir vendor/bundle libv8 -v 3.16.14.7 gem install libv8 -v 3.16.14.7 gem install --install-dir vendor/bundle therubyracer fi

Update: It’s also important to lock down therubyracer and libv8 gems in your Gemfile:

group :production do gem 'unicorn', '~> 4.8.3' gem 'libv8', '~> 3.16.14.7' gem 'therubyracer', '~> 0.12.1' end

Continue Reading