Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nano: update a file after selecting it using the file browser

Tags:

nano

I have no problems when open+change+save a file if I write nano filename on the terminal. But if I open nano and open the File Browser and open a file and try to save it, there is no default file name!:

enter image description here

like image 237
ziiweb Avatar asked Oct 04 '17 11:10

ziiweb


2 Answers

I have tried your problem and indeed found that nano unable to "remember" the filename. My suspicion is that, when you open the editor just by typing "nano" in the command line, it only reads the content of that file, and paste it to the current buffer (without also making a new buffer for opening that file).

So try to do this:
1. Open nano just by typing nano in terminal
2. Then type alt + F to enable nano to open file into separate buffer
3. Read your file of interest from nano by ctrl + R, then ctrl + T
4. Make some modification to the file, and try to save it, It should know the filename of the original file now!

like image 76
hafizhanindito Avatar answered Sep 29 '22 17:09

hafizhanindito


As far as I know, nano doesn't have a default file name feature when invoked with no arguments, if that is what you are asking for.

However, you can set up a shell alias like below to achieve what you're going for. Random hex string to nearly guarantee a unique file wherever it is invoked. You can probably get fancier with a shell function, adding a filename test conditional and invoking custom arguments if they were actually specified.

alias nanod='nano $(head -c16 < /dev/urandom | xxd -pu)'

Single quotes are important; double quotes will result in the subshell being evaluated then the result aliased.

like image 30
JoshuaRLi Avatar answered Sep 29 '22 17:09

JoshuaRLi