Coder Social home page Coder Social logo

masasam / emacs-counsel-tramp Goto Github PK

View Code? Open in Web Editor NEW
59.0 4.0 7.0 11.84 MB

Tramp ivy interface for ssh and docker and ‎vagrant

License: GNU General Public License v3.0

Emacs Lisp 100.00%
emacs emacs-lisp docker vagrant ssh tramp melpa ivy counsel

emacs-counsel-tramp's Introduction

counsel-tramp melpa badge melpa stable badge License: GPL v3

Tramp ivy interface for ssh server and docker and vagrant

Screencast

counsel-tramp-gif

M-x counsel-tramp

counsel-tramp1

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

counsel-tramp2

Filter by counsel.

counsel-tramp3

You can connect your server with tramp.

counsel-tramp4

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

counsel-tramp5

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

counsel-tramp6

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

docker-tramp

If you are using docker-tramp, docker is also supplemented. If you are using vagrant-tramp, vagrant is also supplemented.

docker-tramp1

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 with package.el (M-x package-install counsel-tramp).
You can install docker-tramp.el from MELPA 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 with package.el (M-x package-install vagrant-tramp).

I recommend you are going to install 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/[email protected] will be generated automatically. Even if there is no connection setting in ~/.ssh/config, counsel-tramp can complement like bellow.

emacs-counsel-tramp's People

Contributors

aaronzinhoo avatar gfgkmn avatar masasam avatar swaroopch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

emacs-counsel-tramp's Issues

Make `docker` optional

I do not use docker often, but I do use ssh extensively. However, the counsel-tramp package throws an error if docker is not installed. Can we avoid the hard dependency on docker even for newer versions of Emacs?

Provide default directory to open on remote

I ssh to different remote machines, and the work directory is sometimes different from the home directory that tramp logs in to. Is it possible to make counsel-tramp open a custom default directory when I login to a machine A?

For example, default directory on Machine A is /users/swarnendu and default directory on Machine B is /data/swarnendu.

Use known hosts instead of config

My ssh config has lots of wildcard patterns for hosts under domain names. Basically, my ssh config is useless for getting host names. Specific host names would probably be easier to get out of known hosts.

Cannot connect - docker not installed

Hello, thanks for a great plugin.

I have followed the install instructions and tried all possible settings but when I run M-x counsel-tramp I get "counsel-tramp: ’docker’ is not installed" in Emacs 25.3. Any ideas, perhaps its a setting in Docker I missing... but Docker works

Allow connecting with a different username

I have connections set up in .ssh/config that have a different user name provided through User. However, counsel-tramp seems to always pick up my current login name, which is problematic. Can this be fixed?

FYI, this works fine with regular tramp over ivy/counsel.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.