Gedit
shows the recently opened files.
How do I make gedit
show not only the file-names but also the file path for recently opened files?
I work on a website which has an index.tcl / index.adb
in many locations. So I have for example 3 time index.tcl
. But I'd like to know which one.
A quick hack, just open all files you think you want, then at the top right menu you can find the path of each file, so you can keep what you want and close others.
The cleanest solution would be of course to edit the code of
gedit
. Since that seems out of reach, the solution below is a workaround.If the path information of recently used gedit files is important to you, the soluution can be used as a replacement of gedit's own "recently used" overview. It gives you the information, exactly as it appears on your
gedit
window's title bar, of the last ten used files .It exist of:
gedit
filesSimply run script
[1]
in the background, put script[2]
under a shortcut key or add it as a shortcut to thegedit
launcher's quicklist.The result:
How to setup
The setup needs
wmctrl
to be installed:Then:
Copy the script below (
[1]
) into an empty file, save it asget_latestgedit.py
Copy the script below into an empty file, save it as
get_geditlist.py
:Open a terminal window, test-drive script
[1]
with the command:While the script runs, open a few existing
gedit
files, leave them open for at least 5-10 seconds (the loop break time). Now test-run script[2]
with the command (from another terminal) with the command:The most recent
gedit
files should show up, as shown in the image.If all works fine, add script
[1]
to your startup applications: Dash > Startup Applications > Add. Add the command:and add script
[2]
to a shortcut key: Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:Or,
add it as a quicklist item to your
gedit
launcher, as shown in the image:Copy the
gedit
launcher from/usr/share/applications to
~/.local/share/applications`:Open the local copy in
gedit
:Look for the line:
change it to:
To the very end, add a section to the file:
Of course, replace
python3 /path/to/get_geditlist.py
by the real path to the script[2]
Explanation
Script
[1]
checks (once per five seconds):gedit
windows are opened, by checking if thepidof gedit
has a valid output. Then, if so:gedit
's pid occurs in one or more lines in the output ofwmctrl -lp
. If so, it filters out the lines, not containing a valid path between "(" and ")", since those windows are not from saved files.If the list of recently used windows changes, the list is written to a hidden file in your
home
directory.Script
[2]
reads the hidden file, created and updated by scrip1[1]
. When called:Zenity
list.gedit
.If by any chance, someone's still wondering, gedit has natively implemented showing path of a file in multiple ways. It must've been available for a long time now but v3.36.2 has it for sure.