People never ask for backups, they only ask for restores
My exact words were Don't take my word for it. But when you are desperately trying to recover a program file with no backups and no snapshot, I will abuse you mercilessly.
[https://worldsworstwriter.org/version-control/]
There I was. Editing index.html on a new project. Using nano for general editing [and to avoid the hell of vi command and insert mode] and vi for Unicode characters because Nano was not configured with Unicode support. Something I will soon regret.
user@mba:~> nano -V
GNU nano, version 8.2
(C) 2024 the Free Software Foundation and various contributors
Compiled options: --disable-libmagic --disable-nls --disable-utf8
I spent over an hour adding a new table with 8 of the top 100 Kanji characters in vi.
This is where it went wrong. I moved a large table of Unicode Youon characters in the document. Opened index.html in nano and selected and copied the table. Opened index.html in vi, pasted the table to the new location, deleted the old table location and saved the file. Refreshed the browser and the table was garbled. The table was also garbled in vi, looking like this.
<table> <tr><td></td> <td>?^a^b<br><span class="word">a</span></td> <td>?^a^d<br> <span class="word">i</span></td> <td>?^a^f<br><span class="word">u</span> </td>
It should have looked like this.
<table> <tr><td></td> <td>あ<br><span class="word">a</span></td> <td>い<br><span class="word">i</span></td> <td>う<br><span class="word">u</span></td>
This was my fault for copying the table code from nano, which garbled the Unicode characters without UTF-8 support. I'm thinking No problem, I'll restore the file from backups.
Remember, no matter how bad it is, it can always get worse, spectacularly so. Vi was not backing up any files because I didn't take my own advice and setup initBex. The last nano backup did not contain the Kanji table that I spent an hour tediously adding in vi. Time machine was configured to backup once a day. The manual backups to a Raspberry PI zero, PI3, PI5 and an Imac were several hours old. There was no version control snapshot because the project was new.
Lucky there was a browser tab open with the ungarbled table still intact. Thankfully and mercifully, cut and pasted the table code from the view source browser window to recover the table.
Direct any well deserved abuse to dave@worldsworstwriter.org. If you know a good sauce that makes crow taste better - let me know. Just keep in mind, when this happens to you, I will return the abuse forcefully.
First things first.
Brief notes on adding unicode support to nano: MACOS TERMINAL NANO EDITOR DISPLAY UNICODE # Nano displays unicode characters as ?^W^` # Nano ALT-V does not show verbatim mode # Alt-V shows verbatim input but will not present unicode input mode # Terminal-preferences-profiles-keyboard check "use option as meta key." # user@imac:~> nano -V GNU nano, version 8.2 (C) 2024 the Free Software Foundation and various contributors Compiled options: --disable-libmagic --disable-nls --disable-utf8 # # Nano .configure --enable-utf8 displays error: UTF-8 not supported by ncurses user@imac:~> tic -V ncurses 6.0.20150808 # Install homebrew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # Install ncurses brew install ncurses # Add these lines to .bash_profile for new ncurses environment variables export PATH="/usr/local/opt/ncurses/bin:$PATH" # newer ncurses export LDFLAGS="-L/usr/local/opt/ncurses/lib" # newer ncurses export CPPFLAGS="-I/usr/local/opt/ncurses/include" # newer ncurses # Show version of ncurses pi@mb:~> tic -V ncurses 6.4.20221231 # build nano with utf-8 support .configure --enable-utf8 make sudo make install # nano shows --enable-utf8 pi@mb:~> nano -V GNU nano, version 7.2 (C) 2023 the Free Software Foundation and various contributors Compiled options: --disable-libmagic --disable-nls --enable-utf8 # Add these lines to .bash_profile to set locale to UTF8 export LANG="en_US.UTF-8" # locale utf-8 export LC_ALL="en_US.UTF-8" # locale utf-8 # To Enter Unicode in nano: ALT-V # Should display Verbatim Input Type 2665 # Should display Unicode Input ♥ # 2665 is a Unicode heart
" VI Automatic Backup " Add this to .vimrc to backup files before changes "Turn on backup option set backup "Where to store backups set backupdir=~/.vimbackup/ "Make backup before overwriting the current buffer set writebackup "Overwrite the original backup file set backupcopy=yes "Meaningful backup name, ex: filename@2015-04-05.14:59 au BufWritePre * let &bex = '@' . strftime("%F.%H:%M:%S")
The project I was working on before this happened is here. https://worldsworstwriter.org/jword/
dave@worldsworstwriter.org 2024-10-06