https://github.com/masasam/emacs-counsel-tramp
Tramp ivy interface for ssh and docker and vagrant
https://github.com/masasam/emacs-counsel-tramp
counsel docker emacs emacs-lisp ivy melpa ssh tramp vagrant
Last synced: 7 months ago
JSON representation
Tramp ivy interface for ssh and docker and vagrant
- Host: GitHub
- URL: https://github.com/masasam/emacs-counsel-tramp
- Owner: masasam
- License: gpl-3.0
- Created: 2017-12-04T08:51:15.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-07-14T09:59:20.000Z (over 2 years ago)
- Last Synced: 2024-10-12T22:30:13.085Z (about 1 year ago)
- Topics: counsel, docker, emacs, emacs-lisp, ivy, melpa, ssh, tramp, vagrant
- Language: Emacs Lisp
- Homepage:
- Size: 11.6 MB
- Stars: 59
- Watchers: 4
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# counsel-tramp [![melpa badge][melpa-badge]][melpa-link] [![melpa stable badge][melpa-stable-badge]][melpa-stable-link] [](https://www.gnu.org/licenses/gpl-3.0)
Tramp ivy interface for ssh server and docker and vagrant
## Screencast

M-x counsel-tramp

Display server list from your ~/.ssh/config with counsel interface.

Filter by counsel.

You can connect your server with tramp.

Selecting the list with sudo will lead to the server as root.

Selecting the list of '/sudo:root@localhost:/' will open file at localhost as root.

You can edit your server's nginx.conf on your emacs!

If you are using [docker-tramp](https://github.com/emacs-pe/docker-tramp.el), docker is also supplemented.
If you are using [vagrant-tramp](https://github.com/dougm/vagrant-tramp), vagrant is also supplemented.
You can edit docker container on your emacs!
counsel-tramp-quit
When you finish editing nginx.conf you clean the tramp buffer with `counsel-tramp-quit` command.
## Requirements
- Emacs 24.3 or higher
- counsel 0.10.0 or higher## Installation
You can install `counsel-tramp.el` from [MELPA](http://melpa.org) with package.el
(`M-x package-install counsel-tramp`).
You can install `docker-tramp.el` from [MELPA](http://melpa.org) with package.el
(`M-x package-install docker-tramp`).
If you use Emacs version >= 29.0.60 then docker-tramp is no longer necessary as this functionality is built-in to Tramp.
You can install `vagrant-tramp.el` from [MELPA](http://melpa.org) with package.el
(`M-x package-install vagrant-tramp`).I recommend you are going to install [exec-path-from-shell]( https://github.com/purcell/exec-path-from-shell).
## Sample Configuration
(setq tramp-default-method "ssh")
(define-key global-map (kbd "C-c s") 'counsel-tramp)## If you want to speed up tramp
(add-hook 'counsel-tramp-pre-command-hook '(lambda () (global-aggressive-indent-mode 0)
(projectile-mode 0)
(editorconfig-mode 0)))
(add-hook 'counsel-tramp-quit-hook '(lambda () (global-aggressive-indent-mode 1)
(projectile-mode 1)
(editorconfig-mode 1)))Setting hook that turn off slow extensions when you execute counsel-tramp.
Setting hook that turn on extensions when you execute `counsel-tramp-quit` command.If you don't make a backup files and lockfiles at remote server, it will be saved faster.
(setq make-backup-files nil)
(setq create-lockfiles nil)## Misc setting
Besides ~/.ssh/config, you can add connections manually.
(setq counsel-tramp-custom-connections '(/ssh:domain|sudo:user@localhost:/))
Example when adding more than two connections manually.
(setq counsel-tramp-custom-connections '(/ssh:domain|sudo:user@localhost:/ /ssh:domain2|sudo:user@localhost:/))
If the shell of the server is zsh it is recommended to connect with bash.
(eval-after-load 'tramp '(setenv "SHELL" "/bin/bash"))
If you want to specify the user name to connect with docker-tramp.
(setq counsel-tramp-docker-user "username")
If you want to specify multiple user name list to connect with docker-tramp.
(setq counsel-tramp-docker-user '("username1" "username2" "username3" "username4"))
If you want to change initial directory when connecting with /sudo:root@localhost:.
(setq counsel-tramp-localhost-directory "/var")
## Support for top-level sshconfig include
In addition to normal .ssh/config, it also supports the following format.
~/.ssh/config
Include conf.d/work
Include conf.d/personal~/.ssh/conf.d/work
Host instance
HostName ************
User ************Host archtest
HostName ************
User ************Host debiantest
HostName ************
User ************Host centostest
HostName ************
User ************~/.ssh/conf.d/personal
Host myserver
HostName ************
User ************Host myhost
HostName ************
User ************Below is not support
~/.ssh/config
Include conf.d/**
## Support controlmaster paths
You can use it as follows.
```
(setq helm-tramp-control-master t)
```
Set ~/.ssh/config as below
```
Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p
ControlPersist 30m
ServerAliveInterval 60
```
Execute the ssh command as follows
```
ssh ubuntu@1.1.1.1
```
~/.ssh/master-ubuntu@1.1.1.1 will be generated automatically.
Even if there is no connection setting in ~/.ssh/config, counsel-tramp can complement like bellow./ssh:ubuntu@1.1.1.1:
/ssh:ubuntu@1.1.1.1|sudo:root@1.1.1.1:/[melpa-link]: http://melpa.org/#/counsel-tramp
[melpa-badge]: http://melpa.org/packages/counsel-tramp-badge.svg
[melpa-stable-link]: http://stable.melpa.org/#/counsel-tramp
[melpa-stable-badge]: http://stable.melpa.org/packages/counsel-tramp-badge.svg