I noticed that with i3, I really wanted $mod+Return (the keybinding for opening a new terminal) to start terminal windows in the current working directory. There’s an easy way to achieve this thanks to a program called xcwd.

xcwd prints the working directory of the currently focused window. This works to our advantage in i3, of course!

With urxvt, for example, we can specify the ‘-cd’ option to open a new terminal in a specified directory, ie:

urxvt -cd 'somedir'

So, combined with xcwd, this becomes:

urxvt -cd '`xcwd`'

Where the backticks get the output from the xcwd program. This is a dynamic way to launch new terminals in the current working directory.

We can then set up our i3 config like so:

bindsym $mod+Return exec urxvt -cd "`xcwd`"

and $mod+Return now opens new terminals in the current working directory of the focused application.