nano
имеет параметр времени компиляции для поддержки этой функции в nano.c
, добавлено в Февраль 2011 г. :
#ifndef DISABLE_HISTORIES
else if (ISSET(POS_HISTORY)) {
ssize_t savedposline, savedposcol;
/* If edited before, restore the last cursor position. */
if (check_poshistory(argv[i], &savedposline, &savedposcol))
do_gotolinecolumn(savedposline, savedposcol,
FALSE, FALSE);
}
#endif
Соответствующая запись в журнале изменений -
2011-02-18 Chris Allegretta
* New saved cursor position history option. Command line option -P or --poslog, rc file
entry "poslog". Search history changes to ~/.nano/search_history, cursor position log
is ~/.nano/filepos_history. Added checks to move the legacy .nano_history file to the
new location. Several new functions to files.c: load_poshistory(), save_poshistory(),
check_poshistory(), update_poshistory(), and reworking of histfilename(). New FAQ entry
4.15 discussing the change and offering an interoperability workaround.
Это ifdef'd (может быть недоступно в вашей упакованной версии). Но если доступно, это настраивается с помощью -P
(параметр командной строки) или positionlog
(или poslog
, не рекомендуется) в nanorc
файл.
К сожалению, MacOS содержит поврежденные BSD-версии coreutils. Head также не поддерживает отрицательное число байтов, в то время как его аналог GNU позволяет делать что-то вроде head -c -1
.
В итоге я установил версию coreutils GNU на MacOS:
brew install coreutils
Это устанавливает все основные утилиты, включая split и head с префиксом g
. Так что теперь я могу сделать:
gsplit ${file} -n 4 PREFIX_
И
ghead -c -1 ${file}
Puede encontrar el tamaño del archivo y dividirlo por 4 y usar MacOS split -b
en la cantidad de bytes en su lugar. No tengo una manera de probar esto, pero vagamente:
#!/bin/bash
file=myfile
size=$(stat -f '%z' "$myfile")
let part=size/4
[ "$part" = 0 ] && part=1
split -b "$part" "$myfile"...
No sé qué sucede cuando el tamaño es inferior a 4 bytes y dices split -b 0
, así que hazlo 1. Consulte las páginas man split y stat .