brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: set linenumbers in your nanorc shows line numbers in every nano session

Linux and shell
~/tips/tip-nano-set-linenumbers-nanorc

nano -l file.txt

Turns on line numbers permanently in nano, so you don't need the -l flag each time.

Nano has a flag for line numbers, nano -l, but typing it every time is the kind of small thing that gets old. The same option can live in a config file.

nano -l file.txt

The -l flag is also written --linenumbers and shows line numbers in front of the text. To make it the default, add one line to ~/.nanorc, creating the file if it doesn’t exist:

set linenumbers

A system-wide file, /etc/nanorc, ships with the same line commented out as #set linenumbers, which makes it easy to find the option name. Your own file overrides the system one. Nano also reads ~/.config/nano/nanorc or $XDG_CONFIG_HOME/nano/nanorc, whichever it finds.

While you’re in the file, a few more options in the same list are worth a look. set autoindent keeps the indentation of the previous line, set tabsize 4 changes the tab width, and set tabstospaces types spaces when you press Tab. All three appear in the stock /etc/nanorc as comments.

One caveat: a typo in the file makes nano print an error at startup and ask for a keypress. Check the option names against the sample file. If you only need numbers once, the keybinding in the editor, Alt-n, toggles them on the fly.

Further reading: nanorc manual

More Linux and shell tips zoxide query -ls project eval "$(fzf --bash)" comm --total a.txt b.txt diff -r -x .git -x '*.log' one two printf '%s\n' a b c d e f | xargs -n1 -P3 --process-slot-var=SLOT sh -c 'echo "slot $SLOT got $0"; sleep 0.2' All Linux and shell tips (178) All topics

Link