home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vim45os2.zip / vim-4.5 / tools / remote < prev    next >
Internet Message Format  |  1996-10-07  |  3KB

  1. From: cec@gryphon.gsfc.nasa.gov (Dr. Charles E. Campbell Jr.)
  2. Newsgroups: alt.sources
  3. Subject: A ViM ":r" for files on other machines
  4. Date: 13 Oct 1994 14:41:51 GMT
  5. Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA
  6.  
  7. For those of you who use ViM (vi-improved) by Bram Moolenaar on unix,
  8. here's a command + scriptfile that will allow you to read in files from
  9. other machines.
  10.  
  11. To use this command, type
  12.  
  13.     #r
  14.  
  15. The script will be invoked and will prompt you for machine, filename, etc.
  16. It will optionally use
  17.  
  18.     rcp : if you give a "machine:filename" response
  19.  
  20. or it will use a temporary ftp connection
  21.  
  22.     ftp: if you give a "machine id pass filename" response
  23.  
  24.  
  25. OK, now here's how to do it:
  26.  
  27. Put the following in your .vimrc:  (the ^V and ^M are control characters)
  28.  
  29.     map #r  :w^V^M:!vimrcpfile^V^M:r tmp.vim^V^M:!rm tmp.vim^M
  30.  
  31. The shell script is:
  32.  
  33. #! /bin/ksh -f
  34. #  vimrcpfile
  35. #
  36. #  Author : Dr. Charles E. Campbell, Jr.
  37. #           Goddard Space Flight Center
  38. #           Greenbelt Rd
  39. #           Greenbelt, MD 20771
  40. #
  41. #   Purpose: ftp-s or rcp-s a specified file to <tmp.vim>
  42. #
  43. #   Usage  : vimrcpfile
  44. #            (will prompt the user for what file to obtain)
  45.  
  46. # give prompt and get response
  47. echo 'Enter machine:filename (rcp mode) -or-'
  48. echo 'Enter machine id password filename (ftp mode)'
  49. read -r response
  50. echo "response was <${response}>"
  51.  
  52. # unset all current positional parameters
  53. # set   response into positional parameters
  54. set -- ${response}
  55.  
  56. # issue an rcp or ftp as appropriate
  57. if [ ${#} -eq 1 ]; then
  58.     echo "attempting "'"'"rcp $1 tmp.vim"'"'
  59.     rcp $1 tmp.vim
  60. elif [ ${#} -eq 4 ]; then
  61.     if [ -r ~/.netrc ]; then
  62.         echo "attempting ftp with .netrc pre-existing"
  63.         mv ~/.netrc ~/.netrc.tmp
  64.         echo "machine $1 login $2 password "'"'$3'"' > ~/.netrc
  65.         chmod 600 ~/.netrc
  66.  
  67.         # get the file via ftp
  68.         cat <<EOM | ftp $1
  69.             binary
  70.             get $4 tmp.vim
  71.             quit
  72. EOM
  73.         /bin/rm ~/.netrc
  74.         mv ~/.netrc.tmp ~/.netrc
  75.     else
  76.         echo "attempting ftp with no .netrc"
  77.         echo "machine $1 login $2 password "'"'$3'"' > ~/.netrc
  78.         chmod 600 ~/.netrc
  79.  
  80.         # get the file via ftp
  81.         cat <<EOM | ftp $1
  82.             binary
  83.             get $4 tmp.vim
  84.             quit
  85. EOM
  86.         /bin/rm ~/.netrc
  87.         fi
  88. else
  89.     echo "improper qty (${#}) of arguments"
  90.     /bin/rm -f tmp.vim
  91.     fi
  92. --
  93.         Charles E Campbell, Jr, PhD            _   __   __
  94.         Guidance and Controls Branch (712)    / /_/\_\_/ /
  95.         Goddard Space Flight Center          /_/  \/_//_/
  96.         cec@gryphon.gsfc.nasa.gov                   `-( .....
  97.