Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display path of file in status bar

Tags:

emacs

GNU Emacs 23.1.1

I am wondering is there a way to display the path of the file in the status bar, instead of just the filename.

I have to open many files in many directories, and sometimes I forget what directory they are in. Just easier to display the some of the path in the status bar if that is possible.

Sometimes my directory paths are very long.

for example

/projects/clientserver/trunk/src/client/client.c 

like this in the status bar, just display the last two directories.

/src/client/client.c 

Many thanks for any suggestions,

like image 443
ant2009 Avatar asked May 25 '10 09:05

ant2009


1 Answers

What you are asking is to change the buffer name. You can customize how buffers are named using uniquify. It has several methods for making unique buffer names. The most obvious choice for you is 'forward' which gives exactly what you ask -- prefix the buffer name with part of the path as a prefix.

However, this has a potentially unwanted side effect. Normally, buffer names are made unique by appending a suffix. When you do 'c-x b' to switch buffers, if you type "foo" and you have both "foo" and "foo<1>" you will be shown the common prefix and be given the ability to supply the suffix. So, 'c-x b foo' will let you do completion where you see a list of all of the "foo" buffers.

If you use uniqueify in 'forward' mode, you'll have buffer names of the form "bar/foo" and "baz/foo". Now, 'c-x b foo' won't take you to a foo buffer, or allow you to do completion to get a list of foo buffers. You must remember the prefix that is added to each buffer name.

My advice is to use the 'reverse' mode of uniqify, which uses the directory path as a suffix. It's perhaps slightly less intuitive, but easier to use in practice. So now you would have buffers like "foo\bar" and "foo\baz", again giving you the advantage of being able to do 'c-x b foo' and getting a list of all buffers with a filename of "foo".

So, add this to your .emacs file and see if you like the behavior:

(require 'uniquify) (setq uniquify-buffer-name-style 'reverse) 
like image 84
Bryan Oakley Avatar answered Sep 23 '22 19:09

Bryan Oakley