Display path of file in status bar

后端 未结 5 685
遇见更好的自我
遇见更好的自我 2021-01-30 21:41

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

相关标签:
5条回答
  • 2021-01-30 21:46

    This one works well for me for setting the full path in the frame:

    (setq frame-title-format
      '(:eval
        (if buffer-file-name
            (replace-regexp-in-string
             "\\\\" "/"
             (replace-regexp-in-string
              (regexp-quote (getenv "HOME")) "~"
              (convert-standard-filename buffer-file-name)))
          (buffer-name))))
    
    0 讨论(0)
  • 2021-01-30 21:49

    If you are ok with seeing this as the frame title instead of in the status bar, which I personally prefer because it is less cluttered and is useful also when switching windows with Alt+TAB, etc., then you can add something like the following to your .emacs file without installing any extensions:

    ;; Disable loading of “default.el” at startup,
    ;; in Fedora all it does is fix window title which I rather configure differently
    (setq inhibit-default-init t)
    
    ;; SHOW FILE PATH IN FRAME TITLE
    (setq-default frame-title-format "%b (%f)")
    

    %b will show the buffer name as usual, and %f the full file path. You can of course change the order, add text in between, remove %b, etc.

    0 讨论(0)
  • 2021-01-30 21:57

    See the documentation for the variable 'frame-title-format' It will point you to the variable 'mode-line-format' which details the options for setting your title

    0 讨论(0)
  • 2021-01-30 21:58

    Uniquify should pretty much do what you want.

    0 讨论(0)
  • 2021-01-30 22:01

    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)
    
    0 讨论(0)
提交回复
热议问题