Open dwrz opened 5 years ago
Sorry to revive the dead thread. @dwrz did you find a fix for this perhaps?
@prasoon2211 Sorry, I no longer use shell-pop
. I vaguely recall this issue wasn't just due to shell-pop
, but I'm not very sure.
@prasoon2211 I've had this issue too. It seems to be fixable by advising #'shell-pop--cd-to-cwd-eshell to only run in eshell buffers and only auto-cd when necessary. I've also had to work around another, possibly related, bug involving the buffer directory not being detected properly. Taking the directory part of buffer-file-name seems to work much better then default-directory. With these workarounds shell-pop works well for me using Emacs 27.1 on Debian.
(defun sv/fixed-shell-pop--cd-to-cwd-eshell (cwd)
(if (string= major-mode "eshell-mode")
t
(message "Trying to set eshell CWD (%s) outside of eshell!" cwd)
nil))
(advice-add 'shell-pop--cd-to-cwd-eshell :before-while #'sv/fixed-shell-pop--cd-to-cwd-eshell)
(defun sv/shell-pop (arg)
(interactive "P")
(let ((default-directory
(or (file-name-directory (or (buffer-file-name) "")) default-directory))
(shell-pop-autocd-to-working-dir (stringp (buffer-file-name))))
(shell-pop arg)))
(define-key xah-fly-leader-key-map (kbd "z") #'sv/shell-pop)
config:
(setq shell-pop-default-directory (expand-file-name "~")
shell-pop-shell-type '("eshell" "*eshell*" (lambda () (eshell)))
shell-pop-universal-key nil
shell-pop-window-size 30
shell-pop-full-span t
shell-pop-autocd-to-working-dir t
shell-pop-window-position "bottom")
I found the issue to be problematic when running shell-pop while in an org file with code blocks. If a code block tangles to a relative path, for example #+begin_src :tangle ./setup
, and it intends to tangle to /home/user/code/project1/setup
, after running shell-pop, it would try to tangle to /home/user/setup
instead, as the default-directory
would've changed from /home/user/code/project1/
to /home/user/
.
I haven't tried @SirVolta's solution yet, but i might just use popper.el instead, which can turn any buffer into a pop-up window, so i'll use that and script together a makeshift pop-up terminal instead.
Update: the package multi-term provides a command to create a dedicated pop-up terminal window (multi-term-dedicated-toggle
), just like shell-pop does. There's another called multi-vterm, which only supports vterm (I'm assuming this had to be created because of compatibility issues between vterm and multi-term). I've tried multi-vterm and it works great, but multi-term, the original, doesn't work as well as shell-pop, nor does it support eshell...
When I invoke
shell-pop
, it changes thedefault-directory
of the current buffer toshell-pop-default-directory
.Is it possible to just have
shell-pop-default-directory
apply to the pop up shell, and not to the previously selected buffer?This is with Emacs 26.2 on Linux 5.2.5, x86_64.
Following is my config: