bartman's blog

two terminals one PWD

bartman

I often find myself needing multiple terminals (urxvt) with shells (zsh) in the same directory. The step of entering that directory is teadieous, especially if there are many terminals involved. I have a few tricks that I use to make this faster.

First, I use two shell functions to store the path in the X buffer:

    xpwd () {
        echo $PWD | xclip -i
        xclip -o
    }

    xcd () {
        cd `xclip -o`
    }

I’d run xpwd first in an existing terminal, then start, or switch to, another terminal and run xcd. This relies on the xclip program (apt-get install xclip) which gives the shell access to your X clipboard.

Second, I added Alt-' (or Mod1-apostrophe) to wmii-lua. The view_workdir plugin will keep track of directory changes made in a terminal on that tag. When you push Alt-' wmii-lua will open up a terminal in that same directory.

I have another idea for wmii-lua: to be able to send the same input to all clients in the same view… but that’s not possible yet.

Tags: