summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Isidoro <denis_isidoro@live.com>2019-10-28 17:30:05 -0300
committerDenis Isidoro <denis_isidoro@live.com>2019-10-28 17:30:05 -0300
commit72f75b6f24e1d4c8513e68863dc0896479677093 (patch)
tree8ff6fe636a167baacc213b152d50879b2a866709
parente9ed64bd01b74aabdc2fdf3832627b141a7843dd (diff)
Make it work without columnv0.15.2
-rwxr-xr-xnavi2
-rw-r--r--src/selection.sh2
-rw-r--r--src/str.sh6
3 files changed, 7 insertions, 3 deletions
diff --git a/navi b/navi
index 46292f3..ebda361 100755
--- a/navi
+++ b/navi
@@ -4,7 +4,7 @@ set -euo pipefail
export NAVI_HOME="$(cd "$(dirname "$0")" && pwd)"
source "${NAVI_HOME}/src/main.sh"
-VERSION="0.15.1"
+VERSION="0.15.2"
NAVI_ENV="${NAVI_ENV:-prod}"
opts::eval "$@"
diff --git a/src/selection.sh b/src/selection.sh
index 105eb78..ec62075 100644
--- a/src/selection.sh
+++ b/src/selection.sh
@@ -33,7 +33,7 @@ selection::resolve_ellipsis() {
local -r cheat="$(cheat::from_tags "$cheats" "$tags")"
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)"
echo "${comment2}${SELECTION_ESCAPE_STR}${snippet2}${SELECTION_ESCAPE_STR}${tags2}"
diff --git a/src/str.sh b/src/str.sh
index b817be1..0e39e4b 100644
--- a/src/str.sh
+++ b/src/str.sh
@@ -64,6 +64,10 @@ str::remove_empty_lines() {
sed '/^$/d'
}
+str::last_line() {
+ tail -n1
+}
+
str::as_column() {
local -r txt="$(cat)"
local -r separator="$1"
@@ -71,7 +75,7 @@ str::as_column() {
if command_exists column; then
echo "$txt" | column -t -s "$separator"
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
}