Command line history & tab-completion for sftp in OS X Terminal.app

Check out with-readline. There's an example using sftp there.


Having tried to install with-readline on OSX 10.7.5 I ran into linker errors.

While trying to find a solution to this problem I discovered that MacPorts has a port of OpenSSH which includes the sftp utility compiled with readline support. MacPorts also sets this version of sftp as the default.


You can also try yafc.


Type this into the Terminal:

which sftp

If the result were /usr/bin/sftp, means you are using the macOS built-in SFTP version that is out of date compared two the GNU version. More details here.

You could install the Homebrew version — which is the GNU version — instead

brew install openssh

And list the openssh install path:

brew list openssh

Tou would see some binary here for example:

/usr/local/Cellar/openssh/8.4p1_2/.bottle/etc/ (12 files)
/usr/local/Cellar/openssh/8.4p1_2/bin/scp
/usr/local/Cellar/openssh/8.4p1_2/bin/sftp
/usr/local/Cellar/openssh/8.4p1_2/bin/slogin
/usr/local/Cellar/openssh/8.4p1_2/bin/ssh
/usr/local/Cellar/openssh/8.4p1_2/bin/ssh-add
/usr/local/Cellar/openssh/8.4p1_2/bin/ssh-agent
/usr/local/Cellar/openssh/8.4p1_2/bin/ssh-keygen
/usr/local/Cellar/openssh/8.4p1_2/bin/ssh-keyscan
/usr/local/Cellar/openssh/8.4p1_2/libexec/ (4 files)
/usr/local/Cellar/openssh/8.4p1_2/sbin/sshd
/usr/local/Cellar/openssh/8.4p1_2/share/man/ (15 files)

Now type:

which sftp

the result would be /usr/local/bin/sftp,which is a soft link of /usr/local/Cellar/openssh/8.4p1_2/bin/sftp

Then try the Homebrew version of SFTP and enjoy it!