I have a very simple script aliased in my .bashrc on a remote host that I frequently SSH into for work. It enables me to enter "pth" as a command, and that aliases to "bash /user/your/home/pathprinter.sh", which is as follows:
#!/bin/bash
NOWDIR=`pwd`
echo 'scp [email protected]:'"$NOWDIR"
This enables me to fairly quickly scp a file from my local machine to the remote host or vice versa without having to type very much, because it echos the output, which I then click and drag to highlight, then copy and paste into another terminal window on my local machine.
If this script were stored on my local machine, I could write:
NOWDIR=`pwd`
echo 'scp [email protected]:'"$NOWDIR" | pbcopy
and it would go straight to the clipboard. But if I most frequently am on the remote host when executing this command, and if I do not have sudo powers on remote host (I can still install things on a home directory or elsewhere, however) are there still ways to accomplish this? Anything to save a few seconds!
Instead of echoing the command, the script could run it, so you do not need to copy paste anything.
You can have two scripts, one to copy from remote to local
and another to copy from local to remote
You can execute them as
Or, even better, configure ssh to have a short name for that host
and then you can use directly
scplike thisWith this, if you have public key login with that host, the remote path will be completed when you press
tab, just as if it was a local path!