With the help of wvxvw's answer:
(defvar pwd-orig (getenv "PWD"))
(add-hook 'find-file-hook
(lambda () (setenv "PWD" default-directory)))
(add-hook 'kill-emacs-hook (lambda () (setenv "PWD" pwd-orig)))
Question
I do always work with emacs in no windows mode (emacs -nw) inside Guake, and I have set guake to open a new tab in the same directory on which I'm in that moment.
My purpose is:
PWD variable
) is the same of the file.How can I set my .emacs
file to achieve that?
Solution
With the help of wvxvw's answer:
(defvar pwd-orig (getenv "PWD"))
(add-hook 'find-file-hook
(lambda () (setenv "PWD" default-directory)))
(add-hook 'kill-emacs-hook (lambda () (setenv "PWD" pwd-orig)))
OTHER TIPS
M-xcd
You can use it in .emacs
like this:
(defvar initial-directory (getenv "PWD"))
(cd "~/some-directory/")
(add-hook 'kill-emacs-hook (lambda () (cd initial-directory)))
Sorry, I didn't test the above, but it looks like it would work. (Not sure about how many arguments the 'kill-emacs-hook
takes.