Skip to content

Instantly share code, notes, and snippets.

@chrisb13
Created March 31, 2017 08:02
Show Gist options
  • Save chrisb13/1624534c474e4e849c4de8abba1976fa to your computer and use it in GitHub Desktop.
Save chrisb13/1624534c474e4e849c4de8abba1976fa to your computer and use it in GitHub Desktop.
Bash function to use scp on NCI
function vimnci()
{
if [[ ( $# -eq 0 ) || ( $1 == "--help" ) || ( $1 == "-h" ) ]] ; then
echo "Usage: vimnci PATH_TO."
echo "Purpose: Allows remote editing of files on nci servers..."
echo " "
echo "Mandatory arguments: "
echo "path or file: vim will either edit or open file passed"
echo " "
echo "Example."
echo "This:"
echo "vimnci /home/561/cyb561/repos/scripts_not_in_repo/"
echo " "
echo "Becomes:"
echo "vim scp://[email protected]//home/561/cyb561/repos/scripts_not_in_repo/"
return 1
fi
#number of arguments...
#echo $#
if [ $# == 1 ]
then
vim scp://[email protected]/${1}
fi
if [ $# == 2 ]
then
vim -O scp://[email protected]/${1} scp://[email protected]/${2}
fi
if [ $# == 3 ]
then
vim -O scp://[email protected]/${1} scp://[email protected]/${2} scp://[email protected]/${3}
fi
if [ $# > 3 ]
then
echo 'you passed too many arguments!'
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment