From 7aa39ad678cbcbdc638e03a2b0c50818eb8850f6 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Sun, 12 Nov 2017 02:37:34 -0500 Subject: [PATCH] splitter magic for columns --- scripts/core/inventory.sh | 6 ------ scripts/files/remove_here_if_not_there.sh | 7 ++++++- scripts/rev_control/version_control.sh | 5 +++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/core/inventory.sh b/scripts/core/inventory.sh index e2290d5a..eeb77039 100644 --- a/scripts/core/inventory.sh +++ b/scripts/core/inventory.sh @@ -46,17 +46,11 @@ else fi echo echo "it is $(date +"%A at %H:%M hours on day %e of the %B moon in the gregorian year %Y" | tr A-Z a-z) and our intrepid adventurer $USER is exploring a computer named $(hostname) that is running in a thoughtspace called $osname $osver (code-name $codename), and $USER has deduced that the machine's OS platform is $(uname -m) and its current incarnation has been ${up}." | $splitter -#hmmm: splitter not accepting these args properly right now: -#--mincol 2 --maxcol 40 echo -#echo '++++++++++++++++++++++++++++++++++++++++++' -#echo echo "the following things appear to be lying around here..." echo ls -hFC $color_add echo -#echo '++++++++++++++++++++++++++++++++++++++++++' -#echo echo "there appear to be these entities on this host..." echo who -suT diff --git a/scripts/files/remove_here_if_not_there.sh b/scripts/files/remove_here_if_not_there.sh index 6ba6a4e3..ba0d8dff 100644 --- a/scripts/files/remove_here_if_not_there.sh +++ b/scripts/files/remove_here_if_not_there.sh @@ -3,8 +3,13 @@ function print_instructions() { echo -e "\n$(basename $0 .sh):\n" + +#hmmm: extract to a terminal size function. +# calculate the number of columsn in the terminal. +cols=$(stty size | awk '{print $2}') + echo -e 'this script takes two parameters, a "here" folder and a "there" folder, almost as if it were a copy command. but instead, this removes any file from under the "here" location if it cannot be found in the "there" location. so the "there" location is considered a more definitive template of what should be in "here", such that we strip out what "there" does not have.\n\n -the most" useful way to use this script is for a "here" hierarchy that is a copy of an older version of another "there" hierarchy. the "there" hierarchy may have changed a lot, including new files, changed files, and deleted files. it is a simple operation to copy everything from "there" into "here" (such as by using the command [ cp -R "$there"/* "$here" ] ) , but it is a lot harder to determine what stuff in "here" is out of date and should be removed. that is where this script comes in; it can be run to flush out any older things in "here", rather than requiring the user to manually find all those files. ' | splitter +the most" useful way to use this script is for a "here" hierarchy that is a copy of an older version of another "there" hierarchy. the "there" hierarchy may have changed a lot, including new files, changed files, and deleted files. it is a simple operation to copy everything from "there" into "here" (such as by using the command [ cp -R "$there"/* "$here" ] ) , but it is a lot harder to determine what stuff in "here" is out of date and should be removed. that is where this script comes in; it can be run to flush out any older things in "here", rather than requiring the user to manually find all those files. ' | splitter --maxcol $(($cols - 1)) echo echo "Example Usage:" echo diff --git a/scripts/rev_control/version_control.sh b/scripts/rev_control/version_control.sh index 8c7e9961..7656dc10 100644 --- a/scripts/rev_control/version_control.sh +++ b/scripts/rev_control/version_control.sh @@ -17,6 +17,11 @@ export MAX_DEPTH=5 # use our splitter tool for lengthy output if it's available. if [ ! -z "$(which splitter)" ]; then TO_SPLITTER="$(which splitter)" + +#hmmm: another reusable chunk here, getting terminal size. + # calculate the number of columsn in the terminal. + cols=$(stty size | awk '{print $2}') + TO_SPLITTER+=" --maxcol $(($cols - 1))" else TO_SPLITTER=cat fi -- 2.34.1