Permalink
Browse files

Merge pull request #2 from terencehonles/patch-1

fixed the TODO about showing the full IPv4 address instead of just the first octet
  • Loading branch information...
2 parents d6a97c5 + 7bb5d4e commit ed1bbb0b6e1fdd4b9f64bda438c6fe8238d333a1 @adnichols committed Apr 17, 2012
Showing with 3 additions and 4 deletions.
  1. +3 −4 bin/sc
View
7 bin/sc
@@ -1,13 +1,12 @@
-#!/bin/sh
+#!/bin/bash
# Wrapper to start tmux sessions for connections to hosts
# This is a security test I like to perform - we want to show what
# ssh binary is being used to prevent any trickery
WHICH_SSH=`which ssh`
-# Show only the start of the hostname.
-# TODO: Make this work better with IP addresses (only shows first octet)
-HOST=`echo $1|cut -d. -f1`
+# Show only the IPv4 address or the start of the hostname.
+HOST=`grep -o '^\([0-9]\+\.\)\{3\}[0-9]\+\|^[^.]\+' <<<"${1}"`
# Start tmux window
tmux new-window -n ${HOST} "echo 'Using: $WHICH_SSH' ; ~/bin/sc-ssh ${1}"

0 comments on commit ed1bbb0

Please sign in to comment.