NcFTP Patch

NOTE: From NcFTP client version 3.2.0 this patch is included in the upstream distribution.

When maintaining web pages I often find myself wanting to change a little detail, but usually this means downloading the page via ftp, editing it and then uploading it again. After doing this too many times, I thought that it would be nice to be able to remotely edit the files without leaving the ftp client. Therefore I wrote a patch to the excellent NcFTP client which automates this process.

The patch implements an additional edit command. It reads your favorite editor from the EDITOR environment variable (that would be Vim, if you have any sense :-).

Download

To apply the patch, download the NcFTP client source code and issue the following command from the distribution root directory:

$ patch -p0 < /path_to_patch/ncftp-3.1.9_editcmd.patch

As usual, 'configure && make install' installs the client.

The Gentoo NcFTP package includes this patch by default.

Bookmark TAB Completion

The NcFTP client takes a bookmark title as argument on the command line. This, combined with the programmable completion abilities of bash, makes it possible to TAB complete a bookmark like thrysoee as shown in the below session:

$ ftp <TAB>
gnu   sunsite   thrysoee   mozilla   yurinka   kde   debian

$ ftp th<TAB>

Just paste the following snippet into ~/.bashrc to enable this feature.

alias ftp='ncftp'
NcftpCompletion() {
   local IFS=$'\n'

   BOOKMARKS=$(awk -F',' '/,/ {gsub(" ","\\\\ "); print $1}' \
         ~/.ncftp/bookmarks)
   COMPREPLY=($(compgen -W "$BOOKMARKS" "${COMP_WORDS[COMP_CWORD]}"))
}
complete -F NcftpCompletion ftp

You might also be interested in taking a look at the Bash Programmable Completion Project.