DEV Community

Cover image for XMonad changeDir
Rafa de Castro
Rafa de Castro

Posted on

2

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

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay