Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On ubuntu, is it possible to get the full path to all files currently open in gvim? The results from ps are only a relative path from where gvim was started. My end goal is to generate a shell script of gvim commands which will reopen all of my currently open source files the next time I sit down to work.

share|improve this question
    
Why not to use vim.org/scripts/script.php?script_id=2010 ? Personally I have lots of reasons (e.g. my sessions should exclude all non-projects files opened for reviewing ), but whats yours? –  kagali-san May 31 '11 at 13:19
    
@mhambra: I'm finding myself navigating all over the place to get at source files needed for a particular task. I thought it would be nice to take a snapshot of my gvims to make it quickly get back to this state later. Will that script actually accomplish that? Looks to me like it's more for saving a vim environment... –  Andrew Wood May 31 '11 at 14:16

1 Answer 1

Get PIDs of vim processes:

[srv]~|> ps -C vim -o pid=
4733
4828

Get files opened by PID:

[srv]~|> ls -l /proc/4733/fd
total 0
lrwx------ 1 user grp 64 2011-05-31 14:48 0 -> /dev/pts/1
lrwx------ 1 user grp 64 2011-05-31 14:48 1 -> /dev/pts/1
lrwx------ 1 user grp 64 2011-05-31 14:47 2 -> /dev/pts/1
lrwx------ 1 user grp 64 2011-05-31 14:48 3 -> socket:[54963]
lrwx------ 1 user grp 64 2011-05-31 14:48 5 -> /home/user/.wmark.ps.swp

File opened here: ~/wmark.ps

share|improve this answer
    
How do I know which of the results from ls is the swap file for the file I'm editing? Also, vim doesn't always create a swap file, so this might be somewhat unreliable. –  Andrew Wood May 31 '11 at 13:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.