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

11,990

Solution 1

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

Solution 2

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.

Solution 3

You can also try yafc.

Solution 4

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!

Share:
11,990

Related videos on Youtube

chryss
Author by

chryss

Updated on September 17, 2022

Comments

  • chryss
    chryss almost 2 years

    I use Terminal.app constantly. When connecting via ssh to remote *nix systems, I can continue to use tab to complete command names and arrow-up/down to navigate the command history. However, with sftp this does not work, and I get [-escaped sequences for the latter and a literal tab for the former.

    Any way to get this to work? Anything to do with readline?

  • user2086003
    user2086003 almost 8 years
    The same solution can be applied if you prefer Homebrew, their version of homebrew/dupes/openssh also comes with tab completion.
  • shantanu
    shantanu over 7 years
    Only problem is it's shows password.
  • Jasper de Vries
    Jasper de Vries over 6 years
    .. and it completes based on the local folder, not the remote folder
  • DavidPostill
    DavidPostill over 3 years
    Please do not post the same answer to multiple questions. If the same information really answers both questions, then one question (usually the newer one) should be closed as a duplicate of the other. You can indicate this by voting to close it as a duplicate or, if you don't have enough reputation for that, raise a flag to indicate that it's a duplicate. Otherwise tailor your answer to this question and don't just paste the same answer in multiple places.
  • 傅继晗
    傅继晗 over 3 years
    @DavidPostill Thank you! I'm a newbee and not familier with this.
  • Admin
    Admin about 2 years
    Bear in mind that with the standard OpenSSH (as opposed to the one that is shipped with macOS) you won't be able to save passwords for SSH keys in the macOS Keychain.