forked from rdowinton/homebrew-x11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
terminator.rb
64 lines (55 loc) · 2.07 KB
/
terminator.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class Terminator < Formula
desc "Multiple terminals in one window"
homepage "http://gnometerminator.blogspot.co.uk/p/introduction.html"
url "http://launchpad.net/terminator/trunk/0.97/+download/terminator-0.97.tar.gz"
sha256 "9131847023fa22f11cf812f6ceff51b5d66d140b6518ad41d7fa8b0742bfd3f7"
bottle do
cellar :any
sha256 "362a964719cda836191ff3798dd6da4cf9578c91bf27e5213e36c4d2ea9671b9" => :yosemite
sha256 "a8847d9a30574c788627f36b8d266bc063d2b9078722b25bd705211d8c7f230e" => :mavericks
sha256 "5646394a668c1f010c29c72029503d3a02d8d08c0bb514deee9b9928beb0858d" => :mountain_lion
end
depends_on "pkg-config" => :build
depends_on "intltool" => :build
depends_on :python
depends_on "vte"
depends_on "pygtk"
depends_on "pygobject"
depends_on "pango"
# Patch to fix cwd resolve issue for OS X / Darwin
# See: https://bugs.launchpad.net/terminator/+bug/1261293
patch :DATA
def install
ENV["PYTHONPATH"] = lib+"python2.7/site-packages"
ENV.prepend_create_path "PYTHONPATH", HOMEBREW_PREFIX+"lib/python2.7/site-packages"
system "python", "setup.py", "install", "--prefix=#{prefix}"
bin.env_script_all_files(libexec+"bin", :PYTHONPATH => ENV["PYTHONPATH"])
end
test do
system "#{bin}/terminator", "--version"
end
end
__END__
diff --git a/terminatorlib/cwd.py b/terminatorlib/cwd.py
index 7b17d84..e3bdbad 100755
--- a/terminatorlib/cwd.py
+++ b/terminatorlib/cwd.py
@@ -49,6 +49,11 @@ def get_pid_cwd():
func = sunos_get_pid_cwd
else:
dbg('Unable to determine a get_pid_cwd for OS: %s' % system)
+ try:
+ import psutil
+ func = generic_cwd
+ except (ImportError):
+ dbg('psutil not found')
return(func)
@@ -71,4 +76,9 @@ def sunos_get_pid_cwd(pid):
"""Determine the cwd for a given PID on SunOS kernels"""
return(proc_get_pid_cwd(pid, '/proc/%s/path/cwd'))
+def generic_cwd(pid):
+ """Determine the cwd using psutil which also supports Darwin"""
+ import psutil
+ return psutil.Process(pid).as_dict()['cwd']
+
# vim: set expandtab ts=4 sw=4: