1

Hey, How can I get the current working directory of a VTE widget in Python? Thanks.

ptomato
  • 56,175
  • 13
  • 112
  • 165

2 Answers2

3

Borrowing from Mark, a slightly more elegant approach:

import vte
import os
v = vte.Terminal()
vPid = v.fork_command()
workingDir = os.readlink('/proc/%s/cwd' % vPid)
linuts
  • 6,608
  • 4
  • 35
  • 37
  • Will check this in the morning and see if it works, thanks for your response. –  May 16 '11 at 22:29
1

This is a kludge, but the best way I can think of would be:

import vte
import os
v = vte.Terminal()
vPid = v.fork_command()
# make a system call to pwdx to get working director
sIn, sOut = os.popen2("pwdx " + vPid)
workingDir = sOut.read()
Mark
  • 106,305
  • 20
  • 172
  • 230