Technical Musings: February 2013

Sunday, February 10, 2013

Move over Yahoo Notepad, welcome Github Gist

Github's gist are a pretty good match for a lot of stuff I do; simple one file scripts, not big projects.

I've been putting up a few scripts I've embedded in this blog, and I'm looking through old files for more.  I even have some stuff in an old Yahoo Notepad.  Yea, Yahoo Notepad.  It was/is a simple way to store text files in folders.  No support for sharing, and you had to cut and paste into a form to 'upload' them.  There doesn't seem to be any links in YMail to that system anymore, so you have to go directly to notepad.yahoo.com; but it still works.  I've had a Yahoo account since they first offered them back in 1997.  Unfortunately, during the early times they had pretty restrictive mailbox size limits (I think it started at 5MB), so I had to delete a bunch of stuff back then.  The earliest mail I still have is dated September 5, 2003.

It's terribly thing relegating some of this stuff to Notepad; I had embedded version numbers in the scripts themselves.  Not quite as reliable as Git, I must say.

My Gists:
https://gist.github.com/dgulino

Wednesday, February 6, 2013

OSX SSH Terminal Console Coloring, Redux 2.0

Something about my previous take on this breaks autocompletion in OSX in a weird way: After I finish my first SSH session, tab completion no longer autocompletes. It does provide suggestions as a list, but will not complete the line I'm typing.
I've tried all kinds of things to get this to work, and here's my latest take: simply create a bash script and create an ssh alias to it.
/Users/USERNAME/ash.sh:
#!/bin/bash
ARGS="$@"
A="${ARGS}"
IFS=" "
set -- "$ARGS"
ARGSARRAY=( $@ )
FQDN="${ARGSARRAY[0]}"
IFS="."
set -- "${FQDN}"
FQDNARRAY=( $@ )
HOST="${FQDNARRAY[0]}"
DOMAIN="${FQDNARRAY[1]}.${FQDNARRAY[2]}"
IFS="-"
set -- "${HOST}"
MYARRAY=( $@ )
SERVERTYPE="${MYARRAY[0]}"
ENVNAME="${MYARRAY[1]}"
if [ "${ENVNAME}" = "pro" ]; then
    if [ "${serverType}" = "p19" ]; then
        PROFILE="Basic Green"
    else
        PROFILE="Basic Black"
    fi
elif [ "${ENVNAME}" = "qa" ]; then
    PROFILE="Basic Grey"
elif [ "${ENVNAME}" = "stage" ]; then
    PROFILE="Man Page"
elif [ "${ENVNAME}" = "shadow" ]; then
    PROFILE="Basic Blue"
elif [ "${DOMAIN}" = "test.info" ];then
    PROFILE="Basic Grey"
elif [ "${DOMAIN}" = "test.net" ];then
    PROFILE="Basic Black"
else
    PROFILE="Basic"
fi 
echo "tell app \"Terminal\" to set current settings of \
 first window to settings set \"${PROFILE}\"" | osascript
/opt/local/bin/ssh "${A}"

echo "tell app \"Terminal\" to set current settings of \ 
 first window to settings set \"Basic\"" | osascript 
.profile:
alias ssh='/Users/USERNAME/ash.sh'
This isn't perfect; it doesn't color my csshX sessions, and seems to mess up scp file autocompletion (you use that?). But it's reliable, you don't have to remember anything but 'ssh', and you can use other ssh parameters, as long as the hostname is the first argument.