Hey, How can I get the current working directory of a VTE widget in Python? Thanks.
            Asked
            
        
        
            Active
            
        
            Viewed 848 times
        
    2 Answers
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