2 -- Copyright (c) 2008, Bart Trojanowski <bart@jukie.net>
4 -- This plugin binds Mod1-' to create a terminal with the same working
5 -- directory as the last directory entered on the shell[*] in that view.
7 -- [*] you will have to modify your zshrc or bashrc to generate the
8 -- "ShellChangeDir" wmii event.
11 -- chpwd_functions+='zsh_wmii_chpwd'
12 -- function zsh_wmii_chpwd () { echo "ShellChangeDir $PWD" | wmiir write /event ; }
15 -- function cd () { builtin cd $@ && \
16 -- ( echo "ShellChangeDir $PWD" | wmiir write /event ) ; }
18 local wmii
= require("wmii")
19 local os
= require("os")
20 local io
= require("io")
21 local math
= require("math")
24 local tostring = tostring
26 module("view_workdir")
29 local view_workdirs
= {}
31 wmii
.add_event_handler("ShellChangeDir",
33 wmii
.log("view_workdir: arg is " .. type(arg
))
34 if type(arg
) == 'string' then
35 local view
= wmii
.get_view()
36 wmii
.log("view_workdir: view is " .. type(view
))
37 if type(view
) == 'string' then
38 wmii
.log("view_workdir: view_workdirs["..view
.."] = "..arg
)
39 view_workdirs
[view
] = arg
44 wmii
.add_key_handler("Mod1-apostrophe",
46 local xterm
= wmii
.get_conf("xterm") or "xterm"
49 local view
= wmii
.get_view()
50 wmii
.log("view_workdir: view is " .. type(view
))
51 if type(view
) == 'string' then
52 local dir
= view_workdirs
[view
]
53 if type(dir
) == 'string' then
54 cd_cmd
= "cd '"..dir
.."' ; "
58 wmii
.log (" executing: " .. cd_cmd
.. xterm
)
59 os
.execute (cd_cmd
.. xterm
.. " &")