181 points · by snird · 7y ago · 147 comments
Finally. It was one of the most insane defaults in the history of text editors. Things like this are the reason why it's so hard to recommend nano to beginners.
if [ x$CMDSH = xshell ] ; then
grep -qP $BLKLST <<<"$CMD" && CMD='panic' # skip obviously bad commands like
rm -rf /
# (this isn't a security thing, we just want to catch stupid mistakes)
fiI still use nano 50% of the time because it's so easy to jump into a file, make some quick changes, and jump out. Plus the mark/cut/paste keystrokes are seared into my memory after years of use.
/etc/nanorc is worth a look, at least on Debian it's well commented
This is why I recommend to anyone wanting to try a -nix like OS to learn the basic commands in both vi and nano. One or the other is shipped with every -nix like OS I've ever used. Once they get more used to the OS, go ahead and install whatever editor they want to. But logging into a fresh install of pretty much any system, one can get by with either of the two.
I still use it regularly and it still works well, but I should probably be looking for something else.
I wrote a console-based mail-client with lua-based scripting, over at https://lumail.org/ but I don't think I have more than 50 hard-core users. It seems like most people use mutt, and work around its annoyances, or use web-browser for their mail.
(I realize at some point notmuch came out and became popular, but I've never had a strong feeling for how popular. I think I'm a little biased since I read of people using it, but nobody "local" to me does.)
I was used to pine when mutt came out, so I always used pine or alpine. You can check both out and see which you prefer.
emacs -nw -Q
It boots up quickly and the basic editing defaults are all there. Has the advantage of being everywhere Emacs already is as wellJOVE is tiny, and has implemented a huge amount of emacs. After you spend 15 minutes or so tweaking your .joverc file you won't even notice it's not GNU.
Nano can get partially there, micro is the current best though it has a few MacOS oddities around home/end but can be configured, in the past used ne.
https://gist.github.com/fevangelou/be744753730e86b8783fd481f...
EDIT
I guess I had assumed that vi/vim was significantly more widespread than nano. Maybe that's an outdated assumption? I feel like I've come across a few instances where vi has been the only choice...
Edit: I suspect it's the default because it launches with visible instructions on how to exit. Launching Vim or Emacs strands a lot of new users.
I am sure vi and emacs are much powerful than nano, but the time I'd have to invest in learning them would outweigh the benefit. I just don't edit text files enough for it to pay off.
The edge still goes to vi, especially if you log into older/legacy things, or in very resource constricted environments. It looks like busybox, for instance, has a vi but not a nano: https://busybox.net/BusyBox.html
Are there better, more powerful editors out there? Sure. But just like vim, you can expect to find nano pretty much anywhere, and if you need to make a quick change, say to a configuration file on a bare-bones system, that's nice.
With Emacs/VI you need to bring a HUGE mental framework to just use it.
And maybe, with luck or some years of pain training, to just EXIT it :)
---
Vim/emacs are powerful. Nice? Never. Easy? never. Good for most common editing task in the terminal?. Nope.
Claim that Vim/Emacs are good is like say "why people use Sublime Text when Eclipse is so much better?"
Except, with eclipse, you know how exit it.
That's enough to get by for quick edits. I haven't used vi a ton in my life, but I've managed to remember that much.
With nano, all is straight in the UI. That is powerful, and so obvious.
Why Vim/Emacs not have that?
I know other people who aren't Vim fanatics at all but have occasional work in the terminal, and they too also just learned the most basic Vim commands and have the most basic Vim configurations, if at all.
As a developer who almost exclusively uses GUI editors (Sublime / IntelliJ) I have lost the emacs skills I gained in college, and I don't use emacs enough to remember the key strokes necessary to make it more useful than nano. It's more difficult than nano because I have to google a cheat-sheet every time I use emacs.
I never liked vim.
Nano is a great terminal editor, has enough commands to make me productive when needed, and I use it exclusively for terminal text editing.
Just because the command is "vi" to invoke doesn't mean anything.
I agree, but if anyone is curious, the source is available and has a BSD style license: http://ex-vi.sourceforge.net
Also, do Macs come with vim?
-------------------------------
How to compile and install nano:
Download the nano source code, then:
tar xvzf nano-x.y.z.tar.gz
cd nano-x.y.z
./configure
make
make install
It's that simple. Use --prefix with configure to override the
default installation directory of /usr/local.
If you haven't configured with the --disable-nanorc option, after
installation you may want to copy the doc/sample.nanorc file to
your home directory, rename it to ".nanorc", and then edit it
according to your taste.I’m a daily Nano user and in my experience the only real headache you can run into is missing the right version or configure not finding where readline and nucrses/ncursesw are. Those are really easy to install on any platform (even from source).
There are other Linux distros too. I had openSUSE installed off there not too long back. Theres even Github projects that let you install any ISO onto WSL and wherever on your hard drive you want to install them to.
$ sudo apt update && sudo apt upgrade
Personally, I've ended up back on Debian stable for WSL, because I have reasons to use a VM rather than WSL. So WSL is now just a dumb ssh terminal into a local VM. If you're curious, the reasons are primarily to do with speed of disk access operations. I also run into some issues with several emacs add-ins that I can work around but don't care to.*I also run vcxsrv on Windows, and ssh X forwarding didn't work immediately, but a low-priority to-do is to use this to run local-VM X clients connecting to the Windows X server.
* I sometimes stop to ponder the things that I find acceptable to troubleshoot and the things I don't want to put the effort into. For reference, see above about local VM and X Forwarding....
It’s really as trivial to dist-upgrade Ubuntu on WSL as real Ubuntu.
Heck, I bet 19.04 works fine already if you dare run a beta.
yesssssssssss
The reason why this is (and also why the lines should not be longer than LINE_MAX or contain \0) is that when you simply call fgets() in a loop with LINE_MAX sized buffer, all of these things cause perfectly logical, but wrong/surprising behavior. This is the reason why almost any modern small unix tool contains something called myfgets(), getline() or whatever which wraps fgets() in loop with realloc() and correctly distinguishes eof from other errors.
(I was actually very surprised when vscode _didn't_ do this!)
This is also why tools that have a Unix heritage tend to complain if there is no terminator/separator at the end of the file (even in Windows), like most C compilers.
echo 'this is a test' > test\n
and then echo was adding the newline because you didn't specify -n. echo 'this is a test\n'
doesn't produce an additional new line because -e wasn't specified.Luckily, you usually don't need to do extensive editing there, because you usually can't change much. Most of the changes you'd want to make to config files, etc. also have to go into the next deploy or through some change management process anyway.
You definitely get used to using vi, though.