Skip to content

Bash Version

brookisme edited this page Apr 12, 2018 · 1 revision

Initially I managed my SublimeSFTP config files by adding the bash-script below to my .bash_profile(rc). The functionality is slightly limited but the important pieces are there.

function sublremote {
	if [[ "$1" = "off"  ]]
    then
        echo "SUBL-REMOTE: OFF"
        if [[ -f sftp-config.json  ]]
        then
    	   mv sftp-config.json sftp-config.json.bak
        fi
    elif [[ "$1" = "open" ]]; then
        ip=$( cat sftp-config.json | grep host | xargs sh -c 'echo ${1%,}' )
        url="http://"$ip":8888"
        echo "SUBL-REMOTE: OPENING URL ( "$url" )"
        python -m webbrowser -t $url
	elif [[  -f $1.sftp-config.json ]]
    then
        if [[ -f sftp-config.json  ]]
        then
           mv sftp-config.json sftp-config.json.bak
        fi    	
        echo "SUBL-REMOTE: CONNECT < $1 >"
    	cp $1.sftp-config.json sftp-config.json
	else
    	echo "SUBL-REMOTE: ERROR < config <$1.sftp-config.json> does not exist >"
	fi
}
function sublr {
    sublremote $1
}

Clone this wiki locally