table

Помоћни програм из командне линије за форматирање и приказ CSV-а
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување da8b01c6bd0ff9a0758989c14d88b229322a100d
родитељ 6043742f7d8d15505ad7d81c5b974c56f6d1f251
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Sun,  9 Apr 2023 14:15:21 +0200

Add config.redo, a persistent build configuration file; INSTALL: New file

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
AINSTALL | 30++++++++++++++++++++++++++++++
MREADME | 162++++++++++++++++++++++++++++++++++++-------------------------------------------
Mdefault.o.do | 3+++
Minstall.do | 3+++
Mtable.do | 3+++
Muninstall.do | 3+++
измењених датотека: 6, додавања: 115(+), брисања: 89(-)

diff --git a/INSTALL b/INSTALL @@ -0,0 +1,30 @@ +Prerequisites +============= + +* C compiler (GCC-compatible) - ${TABLE_CC:-gcc -g} +* gzip + + +Install +------- + + $ git clone https://git.sr.ht/~strahinja/table + $ cd table + $ su + +If you have djb redo: + + # redo install + +if you don't: + + # ./do install + + +Persistent build configuration file +----------------------------------- + +If a file config.redo exists in the build directory, it will be sourced when +building targets which also accept configuration through environment variables. +For example, TABLE_CC and PREFIX can be specified in config.redo, eliminating the +need to pass them with each build. diff --git a/README b/README @@ -1,116 +1,101 @@ - table - ===== +table +===== Command line utility to format and display CSV. +For installation instructions, see the file INSTALL. - Install - ------- -$ git clone https://git.sr.ht/~strahinja/table -$ cd table -$ su +Examples +-------- - Then, if you have apenwarr/redo[1]: +Periodically display CPU load information in a single-line table -# redo install + $ watch "table /proc/loadavg -d ' ' -c 50 -n -s ss" - if you don't: +Format a long list of files in the current directory in a double line table with +single-line column divisors -# ./do install + $ LC_ALL=C ls -l | tail -n +2 | sed -e 's/ \+/ /g' | table -d ' ' -n - - Examples - -------- - - Periodically display CPU load information in a single-line table - - $ watch "table /proc/loadavg -d ' ' -c 50 -n -s ss" - - Format a long list of files in the current directory in a double line - table with single-line column divisors - - $ LC_ALL=C ls -l | tail -n +2 | sed -e 's/ \+/ /g' | table -d ' ' -n - - Print information from /etc/passwd in a table: +Print information from /etc/passwd in a table: $ table -n -d : -f 2:1:1:1:5:5:5 /etc/passwd - Configuring GNU Midnight Commander (mc) - --------------------------------------- +Configuring GNU Midnight Commander (mc) +--------------------------------------- - GNU Midnight Commander[2] file manager can be configured to use table as a - viewer (F3) for CSV files. To do that, edit /usr/lib/mc/ext.d/text.sh (or - make and edit a local copy, for example in ~/bin/text.sh, which we will - assume here) so that +GNU Midnight Commander[2] file manager can be configured to use table as a +viewer (F3) for CSV files. To do that, edit /usr/lib/mc/ext.d/text.sh (or make +and edit a local copy, for example in ~/bin/text.sh, which we will assume here) +so that - case "${filetype}" in + case "${filetype}" in - block in do_view_action() function includes: +block in do_view_action() function includes: - csv) - table -m -n "${MC_EXT_FILENAME}" - ;; + csv) + table -m -n "${MC_EXT_FILENAME}" + ;; - You also need to edit extension file (Command->Edit extension file) or just - edit ~/.config/mc/mc.ext and add the lines: +You also need to edit extension file (Command->Edit extension file) or just edit +~/.config/mc/mc.ext and add the lines: - shell/.csv - View=%view{ascii} ~/bin/text.sh view csv %var{PAGER:more} + shell/.csv + View=%view{ascii} ~/bin/text.sh view csv %var{PAGER:more} - before includes and default target. +before includes and default target. - Bonus – TSV viewer: include +Bonus – TSV viewer: include - tsv) - tsvtable -m -n "${MC_EXT_FILENAME}" - ;; + tsv) + tsvtable -m -n "${MC_EXT_FILENAME}" + ;; - in ~/bin/text.sh and +in ~/bin/text.sh and - shell/.tsv - View=%view{ascii} ~/bin/text.sh view tsv %var{PAGER:more} + shell/.tsv + View=%view{ascii} ~/bin/text.sh view tsv %var{PAGER:more} - in ~/.config/mc/mc.ext. +in ~/.config/mc/mc.ext. - Configuring ranger file manager - ------------------------------- +Configuring ranger file manager +------------------------------- - Ranger[3] file manager can be configured to use table as a CSV file viewer. - To do that, add the following to ~/.config/ranger/scope.sh, within the - function handle_extension(): +Ranger[3] file manager can be configured to use table as a CSV file viewer. To +do that, add the following to ~/.config/ranger/scope.sh, within the function +handle_extension(): - ## CSV - csv) - table -m "${FILE_PATH}" && exit 5 - exit 1;; + ## CSV + csv) + table -m "${FILE_PATH}" && exit 5 + exit 1;; - Bonus – TSV viewer: +Bonus – TSV viewer: - ## TSV - tsv) - tsvtable -m "${FILE_PATH}" && exit 5 - exit 1;; + ## TSV + tsv) + tsvtable -m "${FILE_PATH}" && exit 5 + exit 1;; - Configuring vifm - ---------------- +Configuring vifm +---------------- - Vifm[4] file manager can also be configured to use table as a CSV file - viewer. To accomplish this, add the following lines to - ~/.config/vifm/vifmrc: +Vifm[4] file manager can also be configured to use table as a CSV file viewer. +To accomplish this, add the following lines to ~/.config/vifm/vifmrc: - " CSV - fileviewer *.csv - \ table -m %c + " CSV + fileviewer *.csv + \ table -m %c - Bonus – TSV viewer: +Bonus – TSV viewer: - " TSV - fileviewer *.tsv - \ tsvtable -m %c + " TSV + fileviewer *.tsv + \ tsvtable -m %c [1]: https://github.com/apenwarr/redo @@ -119,21 +104,20 @@ $ su [4]: https://vifm.info - License - ------- +License +------- - table - Command line utility to format and display CSV. - Copyright (C) 2020, 2021, 2022, 2023 Страхиња Радић +table - Command line utility to format and display CSV +Copyright (C) 2020, 2021, 2022, 2023 Страхиња Радић - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. +You should have received a copy of the GNU General Public License along with +this program. If not, see <https://www.gnu.org/licenses/>. diff --git a/default.o.do b/default.o.do @@ -1,2 +1,5 @@ redo-ifchange $2.c +if [ -r config.redo ]; then + . config.redo +fi ${TABLE_CC:-gcc -g} -Wall -std=c99 -o $3 -c $2.c diff --git a/install.do b/install.do @@ -1,4 +1,7 @@ redo-ifchange all +if [ -r config.redo ]; then + . config.redo +fi PREFIX=${PREFIX:-/usr/local} BINDIR=$PREFIX/bin DOCDIR=$PREFIX/share/doc/table diff --git a/table.do b/table.do @@ -1,3 +1,6 @@ +if [ -r config.redo ]; then + . config.redo +fi for f in *.h.in; do echo $f | sed -e's/\.in$//g' done | xargs redo-ifchange diff --git a/uninstall.do b/uninstall.do @@ -1,4 +1,7 @@ redo-always +if [ -r config.redo ]; then + . config.redo +fi PREFIX=${PREFIX:-/usr/local} BINDIR=$PREFIX/bin DOCDIR=$PREFIX/share/doc/table