DEV Community

Cover image for XMonad changeDir
Rafa de Castro
Rafa de Castro

Posted on

XMonad changeDir

One of the changes I made in my workflow is stop using tmux, screen or any other terminal manager in my local machine and let XMonad handle everything.

There was a little thing I had using tmux I never managed to solve in XMonad and it is the fact that when I opened a new terminal the current dir was always home directory instead of the base dir of the project I am working on.

I've just recently found WorkspaceDir in xmonad-contrib to let you change your current directory in your workspace.

That creates a beautiful mental model where you spawn a new terminal and it automatically starts in the place you expect it to be.

To do that you just have to assign the shortcut to a call to changeDir :: XPConfig -> X (). For example in my case, using additionalKeysP:

import XMonad.Layout.WorkspaceDir

[...]

("M-c", changeDir <your prompt config>),

[...]

myLayouts = workspaceDir "~" $ <rest of your layout config>


That way you can just pop up a beautiful dialog to change folder:

change folder dialog

You can check my config as a reference.

Photo by Georgie Cobbs on Unsplash

Top comments (0)