fixed itab, though renamed to ntab.

originally from
http://xanana.ucsc.edu/xtal/iterm_tab_customization.html

simplified to https://gist.github.com/924342
This commit is contained in:
Carter Tazio Schonwald 2011-04-17 21:08:45 -04:00
commit 460e2db350

View file

@ -5,53 +5,48 @@ function savepath() {
function tab() {
savepath
osascript >/dev/null <<EOF
on do_submenu(app_name, menu_name, menu_item, submenu_item)
-- bring the target application to the front
tell application app_name
activate
end tell
tell application "System Events"
tell process app_name
tell menu bar 1
tell menu bar item menu_name
tell menu menu_name
tell menu item menu_item
tell menu menu_item
click menu item submenu_item
tell process "Terminal" to keystroke "t" using command down
end
tell application "Terminal"
activate
do script with command "cd \"$PWD\"; $*" in window 1
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end do_submenu
do_submenu("Terminal", "Shell", "New Tab", 1)
EOF
}
function itab() {
savepath
osascript >/dev/null <<EOF
on do_submenu(app_name, menu_name, menu_item)
-- bring the target application to the front
tell application app_name
activate
end tell
tell application "System Events"
tell process app_name
tell menu bar 1
tell menu bar item menu_name
tell menu menu_name
click menu item menu_item
end tell
end tell
end tell
end tell
end tell
end do_submenu
do_submenu("iTerm", "Shell", "New Tab")
EOF
function ntab() {
if [[ $# == 0 ]]; then
ThisDirectory=$PWD
elif [[ $# == 1 && -d "$1" ]]; then
ThisDirectory="$@"
else
print "usage: ntab [directory]"
return 1
fi
osascript <<-eof
tell app "Finder"
activate
tell application "iTerm"
-- make new terminal
tell the front terminal
activate current session
launch session "Default Session"
tell the current session
write text "cd \"$ThisDirectory\""
end tell
end tell
end tell
tell application "Finder"
activate
end tell
tell application "iTerm"
activate
end tell
end tell
eof
}