15

Whenever I close nano after having edited an existing file, it first asks if I'd like to save the file (which is fine), and then asks me to confirm the filename (so I press Enter, since literally 100% of the time I want to keep the same filename).

So I'm wondering, is there any shortcut I can use to avoid having to confirm the filename every time?

  • 2
    The correct answer is: use vim! 😁 – Sparhawk Jun 6 '17 at 13:16
  • If there is an editor you prefer, setting the EDITOR variable will stop most instances of automatic invocation of nano, ie sudo. – hildred Jun 6 '17 at 15:50
11

According to Nano manual

You can configure ~/.nanorc to Save automatically on exit, don't prompt

($:~)=> nano -w ~/.nanorc 

# Save automatically on exit, don't prompt 
set tempfile 

Note: as @cutrightjm commented - the above setting can cause major problems in configurations if you are not careful and modify files and auto-save on exit.

  • 4
    Good suggestion, I would just exercise caution for newer users using this. Often times when I open up config files I'll accidentally put a character or two in it which can cause major problems in configurations if you are not careful – cutrightjm Jun 6 '17 at 13:31
  • That's an interesting prompt they use. – JAB Jun 6 '17 at 19:01
  • @cutrightjm - thanks for the comment, I've updated my answer. – Yaron Jun 6 '17 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.