Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I have term.el (ansi-term) track directories if using anyhting other than bash

When using eshell or ansi-term and bash emacs changes the default-directory variable depending on what directory you are in.

So if I move to /home/user/code/project and then use ido-find-file to open a file it starts ido with the CWD. If I use ksh (my normal shell) or zsh (tried for testing) it doesnt work. Is there a setting or is this just supported under bash?

Thanks

like image 674
Adam Avatar asked Aug 18 '10 01:08

Adam


1 Answers

Put this in your .zshrc:

chpwd() { print -P "\033AnSiTc %d" }

print -P "\033AnSiTu %n"
print -P "\033AnSiTc %d"

The chpwd() function is run every time the pwd changes. The line ending in %d is the one that allows you to track the current directory--I repeat it outside the function to make sure it is run when zsh first initializes. But Emacs requires us to first tell it who the current user is (the line ending in %n).

This is actually explained in term.el, which should be inside /usr/share/emacs//lisp, if you're using Ubuntu.

Hope this helps.

like image 50
ior3k Avatar answered Oct 04 '22 22:10

ior3k