eshion / vim-sync

Automatic sync SFTP,FTP,... for buffers in vim
67 stars 22 forks source link

SFTP Configuration example? #10

Closed baycak closed 6 years ago

baycak commented 7 years ago

Hello,

Can you give me configuration example of sftp? I got confuse with current configuration example on the documentation

If I had this configuration, where should I insert it? Host : 10.3.2.1 username : root password : 123456 dir_location : /var/www/html/test

Thanks for your help. Cheers

ruchee commented 7 years ago
#!/usr/bin/env bash

#----------------------------------------------------------------------

sev_path='/data/www.site.com'     # Remote server project path
loc_path=`dirname $0`             # Local project path

user='root'                       # Server SSH username
host='123.123.123.123'            # Server SSH hostname or IP address
password='RQ1a\[-abcdefg'         # Server SSH password (if has '[' or ']', should replace with '\[' and '\]')

#----------------------------------------------------------------------

if [ 'upload' == $1 ];then
  expect <<END_EXPECT
set timeout -1
spawn sftp $user@$host
expect "\[Pp\]assword:"
send "$password\r"
expect "sftp>"
send "put $loc_path/$2/$3 $sev_path/$2/$3 \r"
expect "100%"
send "quit\r"
expect eof
END_EXPECT

elif [ 'download' == $1 ];then
  expect <<END_EXPECT
set timeout -1
spawn sftp $user@$host
expect "\[Pp\]assword:"
send "$password\r"
expect "sftp>"
send "get $sev_path/$2/$3 $loc_path/$2/$3 \r"
expect "100%"
send "quit\r"
expect eof
END_EXPECT
fi

#----------------------------------------------------------------------

Put these content to a file named .sync

and put .sync to your local project root

chmod a+x .sync

Remember to change your self host info

ruchee commented 7 years ago

Oh,and you should use this patch:

https://github.com/eshion/vim-sync/pull/11/commits/2d04b25680a609dbc1f7fc44f24310e62d7934c9