Thursday, March 14, 2013

Using dirtrack-mode inside shell mode

I usually try to automate the things that I repeatedly perform. One the things that I recently automated was:
  • Create a directory with a prefix and today's date or time as suffix.
  • Chdir to the most recently created directory.
The source code for these utility functions is given below:

When I use these utility functions inside the Emacs' shell-mode, the shell-mode was unable to keep track of the current directory. The issue is that I am changing directories without making use of the cd command.

Then came the dirtrack-mode for the rescue. The idea is very simple: you specify the regular expression where the path appears in your shell prompt. The dirtrack-mode figures out the rest of the stuff.

Now my .emacs file contains the following two lines:

Thats it. Works like a charm. Please note that you might have to modify the regular expression to match where the full path appears in your prompt.

No comments: