From 689b5ab3c8c8bf30ee63cafb8401d7d95e41f359 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 26 Jun 2015 01:48:17 -0400 Subject: [PATCH] osx: fix tab* functions so cd works in iTerm2, exit status is correct, and error messages are not discarded. --- plugins/osx/osx.plugin.zsh | 84 ++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index a6e3a83e6..2cbb95977 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -5,29 +5,35 @@ # VERSION: 1.1.0 # ------------------------------------------------------------------------------ -function tab() { - local command="cd \\\"$PWD\\\"; clear; " - (( $# > 0 )) && command="${command}; $*" - - the_app=$( +function _omz_osx_get_frontmost_app() { + local the_app=$( osascript 2>/dev/null </dev/null < 0 )) && command="${command}; $*" + + local the_app=$(_omz_osx_get_frontmost_app) + + if [[ "$the_app" == 'Terminal' ]]; then + # Discarding stdout to quash "tab N of window id XXX" output + osascript >/dev/null </dev/null < 0 )) && command="${command}; $*" - the_app=$( - osascript 2>/dev/null </dev/null <&2 + false + + fi } function split_tab() { - local command="cd \\\"$PWD\\\"" + local command="cd \\\"$PWD\\\"; clear" (( $# > 0 )) && command="${command}; $*" - the_app=$( - osascript 2>/dev/null </dev/null <&2 + false + + fi } function pfd() {