In order to know that a buffer represents a remote connection, you can use file-remote-p
.
You can read about this function Here
For example, in a shell buffer, (file-remote-p default-directory)
will allow you to differentiate between a local shell and a remote shell.
In order to toggle company-mode, you can call the company-mode
function with a parameter of -1
(negative one).
To perform actions only in a shell buffer, you can add a function hook to the shell-mode-hook
list. You can read about what hooks are and how to use them Here
Putting it all together:
- Write a function that disables company mode in the current buffer only when it is remote:
(defun my-shell-mode-setup-function ()
(when (and (fboundp 'company-mode)
(file-remote-p default-directory))
(company-mode -1)))
- Add this function to your
shell-mode-hook
s
(add-hook 'shell-mode-hook 'my-shell-mode-setup-function)