Search code examples
macososx-yosemitebash

How to alias yafc as sftp on macosx


I tried this and it doesnt work:

alias sftp='yafc sftp://'

I would like to be able to use the shorter sftp syntax from the command line. For example:

sftp [email protected]

rather than having to type this each time

yafc sftp://[email protected]


Solution

  • What you really need is bash function:

    sftp(){
        yafc sftp://"$@"
    }
    

    BAD work-around:
    But if you are keen on using alias & you have password-less authentication enabled, thus not requiring anything to be entered on stdin, then this hacky method will work too (bash 4+):

    alias sftp='(read IP; yafc sftp://"$IP";) <<< '