Skip to main content
edited title
Link
Amelio Vazquez-Reina
  • 43.1k
  • 81
  • 212
  • 302

Mosh ssh/mosh to a remote interactive shell and run specific function

Source Link
Amelio Vazquez-Reina
  • 43.1k
  • 81
  • 212
  • 302

Mosh to a remote shell and run specific function

I have the following alias on my local machine:

alias gom='mosh -- user@host "/path/to/specific/zsh"' 

I use it to connect to a remote machine with an interactive shell. I would like to modify this alias to run a specific function my_func defined in .zshenv in the remote machine as soon as I log in on it (when using this alias).

How can I do so?

I have tried the following:

  • alias gom='mosh -- user@host "/path/to/specific/zsh"; my_func;'
  • alias gom='mosh -- user@host "/path/to/specific/zsh; my_func"'
  • alias gom='mosh -- user@host "/path/to/specific/zsh & my_func"'

Some of the above solutions disconnect me from the remote sessions, while others don't, but none of them work.