Skip to content

Instantly share code, notes, and snippets.

@Ketrel
Created January 28, 2018 16:56

Revisions

  1. Ketrel created this gist Jan 28, 2018.
    34 changes: 34 additions & 0 deletions sshcon.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    #!/bin/sh
    e="\033"
    clu(){
    if [ ! -z ${1} ] && [ $(tput colors) -ge 8 ]; then
    printf "${e}[${1}m"
    fi
    }
    prog=""
    default="server"
    pathmod="/local"
    if [ -z ${1} ]; then
    printf -- "---$(clu '41;1') %b $(clu 0)---\n" "Invalid Use Of Script"
    exit 1
    fi
    #-------------------#
    if [ "${1}" = "local" ] || [ "${1}" = "remote" ]; then
    prog="${default}"
    pathmod="/${1}"
    else
    prog="${1}"
    fi
    #-------------------#
    if [ ! -z ${2} ] && ([ "${2}" = "local" ] || [ "${2}" = "remote" ]); then
    pathmod="/${2}"
    elif [ ! -z ${2} ]; then
    printf -- "---$(clu '41;1') %b $(clu 0)---\n" "Invalid Use Of Script"
    exit 1
    fi
    #-------------------#
    if [ -f "$HOME/Scripts/sshcon_scripts${pathmod}/${prog}" ]; then
    . "$HOME/Scripts/sshcon_scripts$pathmod/${prog}"
    else
    printf -- "---$(clu '41;1') %b $(clu 0)---\n" "Specified Connection Command Invalid"
    fi