From 0a1f6927f0b9c9d979769e9b5af9ff36f08accdf Mon Sep 17 00:00:00 2001 From: Darren 'Tadgy' Austin Date: Sat, 30 Sep 2023 15:31:26 +0100 Subject: [PATCH] Update nanorcs, handle nano differently on Darwin. --- .bashrc | 14 +++++---- .nanorc-2 | 55 +++++++++++++++++++++-------------- .nanorc-6 | 2 +- .nanorc-7 | 2 +- .nanorc-darwin | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 122 insertions(+), 30 deletions(-) create mode 100644 .nanorc-darwin diff --git a/.bashrc b/.bashrc index e5b3a81..ea9796f 100644 --- a/.bashrc +++ b/.bashrc @@ -353,13 +353,15 @@ if [[ "$PLATFORM" = "Linux" ]]; then hash pinfo >/dev/null 2>&1 && alias info='pinfo' hash ping >/dev/null 2>&1 && alias ping='ping -b' elif [[ "$PLATFORM" = "Darwin" ]]; then - # Create .nanorc symlink if necessary. - [[ ! -e "$HOME/.nanorc" ]] && { - NANO_VER="$(command nano --version | awk '/version/ { print $4 }' | cut -d. -f1)" - if [[ -f "$HOME/.nanorc-$NANO_VER" ]]; then - ( cd "$HOME" && ln -sf ".nanorc-$NANO_VER" .nanorc ) || printf "%s: %s\\n" "${BASH_SOURCE##*/}" "failed to create .nanorc symlink" >&2 + # Darwin specific functions. + hash nano >/dev/null 2>&1 && nano() { + if [[ -f "$HOME/.nanorc-darwin" ]]; then + ( cd "$HOME" && ln -sf ".nanorc-darwin" ".nanorc" ) + command nano "$@" + rm -f "$HOME/.nanorc" else - printf "%s: %s\\n" "${BASH_SOURCE##*/}" "no .nanorc for version '$NANO_VER'" >&2 + printf "%s: %s\\n" "${FUNCNAME[0]}" "no .nanorc-darwin found" >&2 + return 1 fi } diff --git a/.nanorc-2 b/.nanorc-2 index 628b0ea..d3965ea 100644 --- a/.nanorc-2 +++ b/.nanorc-2 @@ -16,7 +16,10 @@ ## ", ', ), >, ], and }. ## Use auto-indentation. -# set autoindent +set autoindent + +## When saving a file, create a backup file by adding a tilde (~). +# set backup ## Do case-sensitive searches by default. # set casesensitive @@ -27,12 +30,6 @@ set fill -2 ## Remember the used search/replace strings for the next session. set historylog -## When justifying text, trailing whitespace will automatically be removed. -set justifytrim - -## Enable vim-style lock-files. -set locking - ## Use the blank line below the titlebar as extra editing space. set morespace @@ -45,9 +42,6 @@ set nohelp ## Don't wrap text at all. set nowrap -## Save the cursor position of files between editing sessions. -# set positionlog - ## Do quick statusbar blanking. set quickblank @@ -60,9 +54,6 @@ set smarthome ## Use smooth scrolling as the default. set smooth -## Enable soft line wrapping (AKA full-line display). -# set softwrap - ## Use this spelling checker instead of the internal one. set speller "aspell -x -c" @@ -70,21 +61,41 @@ set speller "aspell -x -c" set suspend ## The two characters used to indicate the presence of tabs and spaces. -# set whitespace >. +set whitespace »· ## Detect word boundaries more accurately by treating punctuation characters as parts of words. set wordbounds -## Interface colours. -set functioncolor magenta -set keycolor brightwhite -set statuscolor magenta -set titlecolor magenta - - ## Include all existing syntax highlight definitions. -include "/usr/share/nano/*.nanorc" +include "/usr/share/nano/asm.nanorc" +include "/usr/share/nano/awk.nanorc" +include "/usr/share/nano/c.nanorc" +include "/usr/share/nano/cmake.nanorc" +include "/usr/share/nano/css.nanorc" +include "/usr/share/nano/debian.nanorc" +include "/usr/share/nano/fortran.nanorc" +include "/usr/share/nano/gentoo.nanorc" +include "/usr/share/nano/groff.nanorc" +include "/usr/share/nano/html.nanorc" +include "/usr/share/nano/java.nanorc" +include "/usr/share/nano/makefile.nanorc" +include "/usr/share/nano/man.nanorc" +include "/usr/share/nano/mgp.nanorc" +include "/usr/share/nano/mutt.nanorc" +include "/usr/share/nano/nanorc.nanorc" +include "/usr/share/nano/objc.nanorc" +include "/usr/share/nano/ocaml.nanorc" +include "/usr/share/nano/patch.nanorc" +include "/usr/share/nano/perl.nanorc" +include "/usr/share/nano/php.nanorc" +include "/usr/share/nano/pov.nanorc" +include "/usr/share/nano/python.nanorc" +include "/usr/share/nano/ruby.nanorc" +include "/usr/share/nano/sh.nanorc" +include "/usr/share/nano/tcl.nanorc" +include "/usr/share/nano/tex.nanorc" +include "/usr/share/nano/xml.nanorc" ## Key bindings. diff --git a/.nanorc-6 b/.nanorc-6 index 8fefd82..52a48e0 100644 --- a/.nanorc-6 +++ b/.nanorc-6 @@ -60,7 +60,7 @@ set nohelp ## Don't add newlines to the ends of files. # set nonewlines -# Save the cursor position of files between editing sessions. +## Save the cursor position of files between editing sessions. # set positionlog ## Do quick statusbar blanking. diff --git a/.nanorc-7 b/.nanorc-7 index 8fefd82..52a48e0 100644 --- a/.nanorc-7 +++ b/.nanorc-7 @@ -60,7 +60,7 @@ set nohelp ## Don't add newlines to the ends of files. # set nonewlines -# Save the cursor position of files between editing sessions. +## Save the cursor position of files between editing sessions. # set positionlog ## Do quick statusbar blanking. diff --git a/.nanorc-darwin b/.nanorc-darwin new file mode 100644 index 0000000..ddc593f --- /dev/null +++ b/.nanorc-darwin @@ -0,0 +1,79 @@ +## Sample initialization file for GNU nano. +## +## Please note that you must have configured nano with --enable-nanorc +## for this file to be read! Also note that this file should not be in +## DOS or Mac format, and that characters specially interpreted by the +## shell should not be escaped here. +## +## To make sure an option is disabled, use "unset