I'm not sure how you can put your local
.zshrc to remote server, (that's without permanently storing it there), this works for me to change my login shell on remote server.
Since it's a shared account, I can use
zsh only for myself with this method.
Add this to your
~/.ssh/config file in your local machine.
HostName <IP, FQDN or DNS resolvable name>
IdentityFile ~/.ssh/<your keyfile>
RemoteCommand zsh -l
There could be hackish way to accomplish what you are looking for, like below.
WARNING This comes with no guarantees and doesn't look 'wise', however I did managed to put my local file to server and source it in login shell using this.
RemoteCommand zsh -l -c 'sleep 1; source /tmp/somefile; zsh'
LocalCommand bash -c 'sftp %r@%h <<< "put /tmp/somefile /tmp/somefile"'
How it works?
RemoteCommand defines what needs to be run on remote side.
LocalCommand defines what needs to be run on local, which is used to copy your local file to remote server for sourcing it. Here is the catch, it happens only after 'successful' connection to remote host.
- Your connection to remote should be open and alive
- Your remote shell doesn't have the file yet, so it has to wait till file is there, ergo
- Your local uses
sftp to put your file to remote server, remote server wakes up from
sleep and sources your scripts.
It's super hackish, I'd like to know if there is a better way, too.
This can be used instead of 'long' sleep time:
RemoteCommand zsh -l -c 'while [[ ! -f /tmp/somefile ]]; do sleep 0.05; done; source /tmp/somefile; zsh'