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.
No comments:
Post a Comment