Skip to content

Instantly share code, notes, and snippets.

@ikuyamada
Created June 18, 2013 06:32
Show Gist options
  • Save ikuyamada/5803088 to your computer and use it in GitHub Desktop.
Save ikuyamada/5803088 to your computer and use it in GitHub Desktop.
A short zshrc snippet that creates new tab on executing ssh in iTerm 2
ITERM_SESSION_NAME=Default
if [ $TERM_PROGRAM = "iTerm.app" ]; then
function new_tab() {
osascript\
-e "tell application \"iTerm\""\
-e "tell the first terminal"\
-e "launch session \"${ITERM_SESSION_NAME}\""\
-e "tell the current session"\
-e "write text \"$1\""\
-e "set name to \"$2\""\
-e "end tell"\
-e "end tell"\
-e "end tell"\
2> /dev/null
}
function ssh_iterm() {
new_tab "clear; /usr/bin/ssh $@; exit" "$@"
}
alias ssh=ssh_iterm
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment