次のシェル スクリプトを変更して目的を達成する方法を知りたいです。
スクリプトは MacVim で使用されます。その目的を説明するために、gVim で .tex ファイルを開くとします。gVim 内でスクリプトを実行すると、新しいターミナル ウィンドウが開き、LaTeXmk (.tex ファイルを自動的にコンパイルするプログラム) が実行を開始し、gVim で開かれた .tex ファイルをコンパイルします。
このプロセスでは、2 つのターミナル ウィンドウが開きます。1 つは開始ウィンドウ (単なる $ プロンプト) 用で、もう 1 つは LaTeXmk が実行中であることを示しています。LaTeXmk が実行されると、最初のウィンドウは必要ないため、スクリプトが呼び出された後に自動的に閉じたいと考えています。
最初のターミナル ウィンドウを自動的に閉じるようにスクリプトを変更する方法を誰か教えてもらえますか?
#!/bin/sh
#
# Open a new Mac OS X terminal window with the command given
# as argument.
#
# - If there are no arguments, the new terminal window will
# be opened in the current directory, i.e. as if the command
# would be "cd `pwd`".
# - If the first argument is a directory, the new terminal will
# "cd" into that directory before executing the remaining
# arguments as command.
# - If there are arguments and the first one is not a directory,
# the new window will be opened in the current directory and
# then the arguments will be executed as command.
# - The optional, leading "-x" flag will cause the new terminal
# to be closed immediately after the executed command finishes.
#
# Written by Marc Liyanage <http://www.entropy.ch>
#
# Version 1.0
#
if [ "x-x" = x"$1" ]; then
EXIT="; exit"; shift;
fi
if [[ -d "$1" ]]; then
WD=`cd "$1"; pwd`; shift;
else
WD="'`pwd`'";
fi
COMMAND="cd $WD; $@"
echo "$COMMAND $EXIT"
osascript 2>/dev/null <<EOF
tell application "Terminal"
activate
do script with command "$COMMAND $EXIT"
end tell
EOF
でスクリプトを見つけました
http://vim.1045645.n5.nabble.com/latexmk-from-macvim-tt1212353.html
スレッドで同様の質問をしましたが、これまでに回答がありません。このスクリプトは非常に便利で、他の LaTeX ユーザーにも役立つと思います。