Last active
June 9, 2018 13:38
-
-
Save nguyent/a8dbb6012f0b5c1bb139bbb10cbf939e to your computer and use it in GitHub Desktop.
recursive directory listing piped into fzf for scp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| remotecp() | |
| { | |
| server=myserver | |
| remote_directory=filedirectory | |
| # get full file names, slashes, and put everything in quotes (for strings with spaces yo) | |
| filename=$(ssh $server "tree ${remote_directory} -afFiQ --prune | head -n -2" | fzf) | |
| cmd=(scp) | |
| # recursive copy for bash | |
| if [ "${filename: -1}" = / ]; then | |
| cmd+=(-r) | |
| fi | |
| cmd+=($server:$filename .) | |
| #cmd=(echo $filename) | |
| ${cmd[@]} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment