Created
          October 3, 2020 04:01 
        
      - 
      
- 
        Save Spaceghost/357ad4380e2be7e382d411a619edebe5 to your computer and use it in GitHub Desktop. 
    autossh combined with tmux for a mosh like behaior
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function smux { | |
| AUTOSSH_POLL=10 | |
| AUTOSSH_PORT=$(awk 'BEGIN { srand(); do r = rand()*32000; while ( r < 20000 ); printf("%d\n",r) }' < /dev/null) | |
| #AUTOSSH_GATETIME=30 | |
| #AUTOSSH_LOGFILE=autossh.$HOST.log | |
| #AUTOSSH_DEBUG=yes | |
| #AUTOSSH_PATH=/usr/local/bin/ssh | |
| export AUTOSSH_POLL AUTOSSH_LOGFILE AUTOSSH_DEBUG AUTOSSH_PATH AUTOSSH_GATETIME AUTOSSH_PORT | |
| case "$2" in | |
| "") autossh $@ -t "if tmux -qu has; then tmux -qu attach; else EDITOR=vim tmux -qu new; fi";; | |
| *) autossh $@ -t "if tmux -qu has -t $2; then tmux -qu attach -t $2; else EDITOR=vim tmux -qu new -s $2; fi";; | |
| esac | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment