This pull request adds cdp (cd to project) shell function. In your terminal, you can type this command to go to the root of the project you are opening now. Needs emacsclient.
Add cdp shell function
When no emacs server is running I get the following error message and one new emacs instance with lots of file buffers named after source provided to emacsclient instead:
emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".
/home/a00001/.bin/editor: line 13: [: too many arguments
Maybe it's worth fixing
Ive modified it a bit
Now it looks like this::
# Go to currently active project root in Emacs
local EMACS_CWP=$(emacsclient -a false -e "
(nth 1 (assoc 'buffer-list
(nth 1 (nth 1 (current-frame-configuration)))))))
(or (ignore-errors (eproject-root current-buffer))
(let ((filename (buffer-file-name)))
" 2>/dev/null | sed 's/^"\(.*\)"$/\1/')
if [ -d "$EMACS_CWP" ]; then
Thanks for the review! I agree with your points except for hiding errors from Emacs. Why not just show them?
Can you send a pull request to my shell-utils branch? That way your change will show up here. I just don't want to take your credit. :)
ok., lets show the errors. i'll make the pull req.
make cdp alias more fault tolerant.
Merged tkf#1. Thanks.
This is clever and will probably prove quite useful.
I'd prefer if that Lisp code was in a .el file, however, so it's easier to edit and tweak. The shell script should then look like: emacsclient -a false -e "(eproject-print-current-project-working-directory)" or something like that.
emacsclient -a false -e "(eproject-print-current-project-working-directory)"
I'll merge this for now, however, as it's not a really big problem 😄