Alex
Alex

Reputation: 540

Keep ZSH config when entering remote machine via ssh

I was wondering if there was a way to keep the formatting, functionality and aliases I've set up with ZSH locally whenever I enter a remote machine via SSH. Currently, as I would expect without any type of configuration, it defaults to a standard terminal.

I am on Ubuntu 19.10 running zsh 5.7.1 in the terminal application.

Upvotes: 1

Views: 3759

Answers (2)

For you stranger
For you stranger

Reputation: 1

Maybe someone need an answer.

You can configure your config file for remote connecting by ssh. Create or modify file that is located by the path

~/.ssh/config

In the file you can declare sections for each of your connections. For keep using your local cmd environment you need to pass two necessarily parameters RequestTTY to value "yes" for requesting for using pseudo terminal and the second one is RemoteCommand to value "zsh". This is the command that will be executed in the requested pseudo terminal.

There is an example of config settings.

Host first
  Hostname 192.168.0.111
  User izumra
  RequestTTY yes
  RemoteCommand zsh

Upvotes: -1

LookAheadAtYourTypes
LookAheadAtYourTypes

Reputation: 1699

Please look at this repository:

https://github.com/romkatv/zsh4humans

It advertises itself with:

SSH

When you connect to a remote host over SSH, your local Zsh for Humans environment gets teleported over to it. The first login to a remote host may take some time. After that it's as fast as normal ssh.

Under the hood it is described to work like this:

  1. Archives Zsh config files on the local host and sends them to the remote host.
  2. Extracts Zsh config files on the remote host.
  3. Sources %U.zshenv%u with Z4H_BOOTSRAPING=%F{3}'1'%f, which starts the usual %Bzsh4humans%b bootstrap process.

Maybe this is not as specific answer that you would be happy with but you can dig there to find something useful.

Upvotes: 1

Related Questions