Skip to content

Instantly share code, notes, and snippets.

@mwild1
Created January 13, 2022 11:31
Show Gist options
  • Save mwild1/1992cff46bf3092dfe4a797671f3c7bc to your computer and use it in GitHub Desktop.
Save mwild1/1992cff46bf3092dfe4a797671f3c7bc to your computer and use it in GitHub Desktop.
Config snippet for Awesome WM to spawn terminal in current directory
--[[
This snippet works with rxvt-unicode. If you hit Mod+Return while
you have a terminal window focused, the new terminal window will
begin in the same directory instead of the default (your home directory).
--]]
awful.key({ modkey, }, "Return", function ()
local extra_args = "";
local curr_client = client.focus;
if curr_client and curr_client.class == "URxvt" then
local shell_pid = io.popen("ps h --ppid "..curr_client.pid.." -o pid"):read("*l"):gsub("%s+", "");
extra_args = " -cd /proc/"..shell_pid.."/cwd";
end
awful.util.spawn(terminal..extra_args)
end, { description = "open a terminal" });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment