Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ? 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

Get PIDs of vim processes:

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

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/

File opened here: ~/

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .