分类: LINUX
2012-02-24 18:00:51
import os,time,thread
import vim
import subprocess
def child(tid):
pip = subprocess.Popen(['/home/zrf/test.sh'], shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while True:
pip.poll()
if pip.returncode != None:
break
line = pip.stdout.readline()
# Store current window
cur_win = vim.eval("winnr()")
# Switch to the last window
vim.command( vim.eval("winnr('$')") + "wincmd w" )
vim.current.buffer.append(line)
vim.command("redraw | $")
# Restore the origin window
vim.command( cur_win + "wincmd w")
#time.sleep(0.1)
# Store current window
cur_win = vim.eval("winnr()")
# Switch to the last window
vim.command( vim.eval("winnr('$')") + "wincmd w" )
vim.current.buffer.append("===== Finished =====")
vim.command("redraw | $")
# Restore the origin window
vim.command( cur_win + "wincmd w")
thread.start_new(child, (1,))