5

Windows 10, Emacs 25.1.

Suppose I open file D:/temp/test/myfile.txt. But in the in the mode line show only file name (myfile.txt).

But I need to show FULL path to file: D:/temp/test/myfile.txt

This path can show on mode line OR in the frame title. How I can do this?

yPhil
  • 973
  • 6
  • 22
a_subscriber
  • 4,062
  • 1
  • 18
  • 56

3 Answers3

7

The variable buffer-file-name contains an absolute path of the file you are visiting.

To use in frame title:

    (setq frame-title-format
          '("" invocation-name ": "
            (:eval
             (if buffer-file-name
                 (abbreviate-file-name buffer-file-name)
               "%b"))))

To use it in the mode-line you can do the same, but for mode-line-format variable. If you need more help see C-h v mode-line-format

You can also use %f, like (setq-default frame-title-format "%b (%f)")

For a more thorough explanation see here and here

Stefan
  • 26,404
  • 3
  • 48
  • 85
fhdhsni
  • 693
  • 6
  • 16
  • +1 for mentioning C-h v mode-line-format. I would only add that that same docstring explains the meaning of identifiers like %b, %f, and many more, which apply to both mode-line-format and frame-title-format. From C-h v frame-title-format: This variable has the same structure as ‘mode-line-format’, except that the %c, %C, and %l constructs are ignored. It is used only on frames for which no explicit name has been set (see ‘modify-frame-parameters’). – Kaushal Modi Jun 08 '17 at 16:52
1

To show the current file path in the minibuffer you can do this:

(setq-default mode-line-buffer-identification
              (list 'buffer-file-name
                    (propertized-buffer-identification "%12f")
                    (propertized-buffer-identification "%12b")))
yPhil
  • 973
  • 6
  • 22
  • 1
    Thank you for sharing!! This should be the official answer b/c it actually answers the question, rather than answering another question and redirecting to dense documentation. – aec Nov 10 '22 at 02:32
0

Did as follows:

Began installing xdotool package via apt install xdotool.

Then ran it via xdotool getactivewindow getwindowgeometry to get desired destination position, which gave me following output:

Window 69206023
  Position: 2201,251 (screen: 0)
  Geometry: 774x568

Entered it in a script, as:

#!/bin/bash
xdotool getactivewindow windowmove 2201 251 windowsize 774 568

Finally copied into /usr/bin/moveright and binded it on desired keystroke.

Ronald71
  • 184
  • 5