I know I can run M-x pwd
which will give me Directory ~/
or something like that. Can I get it without the "Directory" bit?
Thank you very much.
You could also add
(setq my-initial-directory default-directory)
to your Emacs init file.
In that way, you could later access the directory where Emacs was launched by evaluating my-initial-directory
..
Check the default-directory
variable.
default-directory
changes with each found file. I'd like to find the "working directory" where Emacs have been launched.
Commented
Apr 30, 2015 at 9:37
M-x pwd
just prints the message with the value of the variable default-directory
Commented
Apr 30, 2015 at 10:45
I just found out I can do (getenv "PWD")
on Linux on bash. I'm not sure if there's a better (more platform-agnostic and Emacs) way to do so.
You can evaluate (call-process "pwd" nil t)
, e.g. typing M-:
(call-process "pwd" nil t)
RET
. This will run Unix pwd
command and insert its output at the point in the current buffer, if the buffer is not read-only. It's not clear from the question what for and why you need the current directory without Directory
prefix.