Set title bar text in nano

140 Views Asked by At

I use nano (version version 4.8) to edit temporary files. The title bar shows the name of the temp file, which isn't very useful. I'd rather it say something like "config for whatever" or something custom like that. I've looked through the flags but I can't find anything that does that. Is there a command line flag or some other way to set a custom title?

1

There are 1 best solutions below

0
Marijn On

Nano shows the command line argument in the title bar, which cannot be changed. However, you can of course change what you put in the command line.

In Linux or Mac this can be done in a more or less canonical way by making a symlink and editing that symlink instead of the real file. Because it is a symlink, changes will automatically be reflected in the original file. After editing you can unlink the file.

Small bash script that does this, for example called titlenano.sh:

#!/bin/bash
ln -s "$1" "$2"
nano "$2"
unlink "$2"

Example call:

$ ./titlenano.sh tmp12345.txt "config for whatever"

Result:

enter image description here

Note that saving the file now also uses the symlink name, so it is not easy to see from the editor what the original filename was.

On Windows you can do something similar by just making a copy of the file with a different name, editing the copy, then copy it back and remove the copy.