modified ntabs to work with both iterm and term!

has the correct no arg and arg behavior for both

-Carter
This commit is contained in:
Carter Tazio Schonwald 2011-04-17 21:41:46 -04:00
commit 1680c0943b

View file

@ -1,9 +1,6 @@
function savepath() {
pwd > ~/.current_path~
}
function tab() { function tab() {
savepath
osascript >/dev/null <<EOF osascript >/dev/null <<EOF
tell application "System Events" tell application "System Events"
tell process "Terminal" to keystroke "t" using command down tell process "Terminal" to keystroke "t" using command down
@ -19,6 +16,7 @@ EOF
function ntab() { function ntab() {
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
ThisDirectory=$PWD ThisDirectory=$PWD
elif [[ $# == 1 && -d "$1" ]]; then elif [[ $# == 1 && -d "$1" ]]; then
@ -28,25 +26,38 @@ else
return 1 return 1
fi fi
osascript <<-eof
tell app "Finder" if [[ $TERM_PROGRAM != iTerm.app ]]; then
activate
tell application "iTerm" osascript -e "tell application \"System Events\"
-- make new terminal tell process \"Terminal\" to keystroke \"t\" using command down
tell the front terminal end
activate current session tell application \"Terminal\"
launch session "Default Session" activate
tell the current session do script with command \"cd \\\"$ThisDirectory\\\"\" in window 1
write text "cd \"$ThisDirectory\"" end tell"
end tell return 1
end tell else
end tell osascript -e " tell app \"Finder\"
tell application "Finder" activate
activate tell application \"iTerm\"
end tell -- make new terminal
tell application "iTerm" tell the front terminal
activate activate current session
end tell launch session \"Default Session\"
end tell tell the current session
eof write text \"cd \\\"$ThisDirectory\\\"\"
} end tell
end tell
end tell
tell application \"Finder\"
activate
end tell
tell application \"iTerm\"
activate
end tell
end tell"
fi
}