Make it work without column

This commit is contained in:
Denis Isidoro 2019-10-28 17:30:05 -03:00
parent e9ed64bd01
commit 72f75b6f24
3 changed files with 7 additions and 3 deletions

2
navi
View file

@ -4,7 +4,7 @@ set -euo pipefail
export NAVI_HOME="$(cd "$(dirname "$0")" && pwd)" export NAVI_HOME="$(cd "$(dirname "$0")" && pwd)"
source "${NAVI_HOME}/src/main.sh" source "${NAVI_HOME}/src/main.sh"
VERSION="0.15.1" VERSION="0.15.2"
NAVI_ENV="${NAVI_ENV:-prod}" NAVI_ENV="${NAVI_ENV:-prod}"
opts::eval "$@" opts::eval "$@"

View file

@ -33,7 +33,7 @@ selection::resolve_ellipsis() {
local -r cheat="$(cheat::from_tags "$cheats" "$tags")" local -r cheat="$(cheat::from_tags "$cheats" "$tags")"
local -r tags2="$(echo "$cheat" | head -n1 | str::sub 2)" local -r tags2="$(echo "$cheat" | head -n1 | str::sub 2)"
local -r comment2="$(echo "$cheat" | grep "$comment" | str::sub 2)" local -r comment2="$(echo "$cheat" | grep "$comment" | str::last_line | str::sub 2)"
local -r snippet2="$(echo "$cheat" | grep "$comment2" -A 999| str::last_paragraph_line)" local -r snippet2="$(echo "$cheat" | grep "$comment2" -A 999| str::last_paragraph_line)"
echo "${comment2}${SELECTION_ESCAPE_STR}${snippet2}${SELECTION_ESCAPE_STR}${tags2}" echo "${comment2}${SELECTION_ESCAPE_STR}${snippet2}${SELECTION_ESCAPE_STR}${tags2}"

View file

@ -64,6 +64,10 @@ str::remove_empty_lines() {
sed '/^$/d' sed '/^$/d'
} }
str::last_line() {
tail -n1
}
str::as_column() { str::as_column() {
local -r txt="$(cat)" local -r txt="$(cat)"
local -r separator="$1" local -r separator="$1"
@ -71,7 +75,7 @@ str::as_column() {
if command_exists column; then if command_exists column; then
echo "$txt" | column -t -s "$separator" echo "$txt" | column -t -s "$separator"
else else
echo "$txt" | awk -F "$separator" -vOFS='\t' 'NF > 0 { $1 = $1 } 1' echo "$txt" | awk -F "$separator" -vOFS=' ' 'NF > 0 { $1 = $1 } 1'
fi fi
} }