According to the man page for GNU nano 2.9.3, you can use the -l
or --linenumbers
flags.
-l, --linenumbers
Display line numbers to the left of the text area.
Alternatively, according to the man page for nanorc, you can add set linenumbers
in ~/.nanorc
, $XDG_CONFIG_HOME/nano/nanorc
or ~/.config/nano/nanorc
.
INITIALIZATION FILE
nano will read two configuration files: first the system's nanorc (if
it exists), and then the user's nanorc (if it exists), either ~/.nanorc
or $XDG_CONFIG_HOME/nano/nanorc or ~/.config/nano/nanorc, whichever is
encountered first. See nanorc(5) for more information on the possible
contents of those files.
set linenumbers
Display line numbers to the left of the text area.
Edit
In response to comments about alternate config files, from the description of man nanorc
:
During startup, nano will first
read the system-wide settings, from /etc/nanorc (the exact path might be different on your
system), and then the user-specific settings, either from ~/.nanorc or from $XDG_CON‐
FIG_HOME/nano/nanorc or from ~/.config/nano/nanorc, whichever is encountered first.
I would not typically advise others to change the system-wide config file, unless you have a good reason to do so, as it will likely be overwritten during any updates, and is not likely to be included in system backups, which typically only include the home directory.
I have no idea why (never really understood the escape codes), but adapting the other prompt seems to work:
PS1='\[\033[1;32m\][\W]\$ \[\033[00m\]'
Apparently, you need to enclose the escape sequences in \[...\]
, to tell bash not to count them while determining the prompt width. Therefore, both the above PS1 and the following would work equally well:
PS1='\[\e[1;32m\][\W]\$ \[\e[m\]'
Best Answer
You can use Ctrl+K to delete a line.
But strictly speaking Ctrl+k does not delete lines permanently. The most recent set of deletions are stored in a buffer. These lines may be re-inserted at the current cursor location using Ctrl+U. You can use this to cut and paste.
Here you can find some useful shortcuts of
nano