Skip to content

Instantly share code, notes, and snippets.

@felixbuenemann
Created June 24, 2013 23:41
Show Gist options
  • Save felixbuenemann/5854725 to your computer and use it in GitHub Desktop.
Save felixbuenemann/5854725 to your computer and use it in GitHub Desktop.
require 'formula'
class Zsh5Installed < Requirement
fatal true
satisfy :build_env => false do
which('zsh') && `zsh --version|awk '{print $2}'|cut -d. -f1`.to_i == 5
end
def message; <<-EOS.undent
Zsh 5.x is required to install.
You can install it with:
brew install zsh
EOS
end
end
class Zpython < Formula
homepage 'https://bitbucket.org/ZyX_I/zsh'
url 'http://www.zsh.org/pub/zsh-5.0.2.tar.bz2'
mirror 'http://sourceforge.net/projects/zsh/files/zsh/5.0.2/zsh-5.0.2.tar.bz2'
sha1 '9f55ecaaae7cdc1495f91237ba2ec087777a4ad9'
head 'https://bitbucket.org/ZyX_I/zsh.git', :branch => 'zpython'
depends_on Zsh5Installed
depends_on :python
depends_on :autoconf => :build
def patches
{:p1 => "https://gist.github.com/felixbuenemann/5790777/raw/cb5ea3b34617174e50fd3972792ec0944959de3c/zpython.patch"}
end unless build.head?
def install
args = %W[
--disable-gdbm
--enable-zpython
]
inreplace "configure.ac", "config.c", "config.c.in" if MacOS.version >= :mavericks
system "autoreconf"
system "./configure", *args
# Disable building docs due to exotic yodl dependency
inreplace "Makefile", "subdir in Src Doc;", "subdir in Src;"
system "make"
(lib/"zpython/zsh").install "Src/Modules/zpython.so"
end
def test
system "zsh -c 'zmodload zsh/zpython && zpython print 42'"
end
def caveats; <<-EOS.undent
To use the zpython module in zsh you need to
add the following line to your .zshrc:
module_path=($module_path #{HOMEBREW_PREFIX}/lib/zpython)
If you want to use this with powerline, make sure you set
it early in .zshrc, before your prompt gets initialized.
After reloading your shell you can test with:
zmodload zsh/zpython && zpython 'print "hello world"'
EOS
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment