mirror of
https://github.com/denisidoro/navi
synced 2024-11-24 20:43:06 +00:00
parent
4792621b8c
commit
78638c67e4
9 changed files with 28 additions and 15 deletions
2
navi
2
navi
|
@ -35,7 +35,7 @@ source "${SCRIPT_DIR}/src/main.sh"
|
|||
##? full docs
|
||||
##? Please refer to the README at https://github.com/denisidoro/navi
|
||||
|
||||
VERSION="0.11.0"
|
||||
VERSION="0.11.1"
|
||||
NAVI_ENV="${NAVI_ENV:-prod}"
|
||||
|
||||
opts::eval "$@"
|
||||
|
|
|
@ -8,7 +8,6 @@ export SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|||
files_to_lint() {
|
||||
find . -iname '*.sh'
|
||||
find scripts/*
|
||||
find shell/*
|
||||
echo "${SCRIPT_DIR}/test/run"
|
||||
echo "${SCRIPT_DIR}/navi"
|
||||
}
|
||||
|
|
|
@ -36,8 +36,12 @@ arg::next() {
|
|||
|
||||
arg::deserialize() {
|
||||
local arg="$1"
|
||||
|
||||
arg="${arg:1:${#arg}-2}"
|
||||
echo "$arg" | tr "${ARG_DELIMITER}" " " | tr "${ARG_DELIMITER_2}" "'" | tr "${ARG_DELIMITER_3}" '"'
|
||||
echo "$arg" \
|
||||
| tr "${ARG_DELIMITER}" " " \
|
||||
| tr "${ARG_DELIMITER_2}" "'" \
|
||||
| tr "${ARG_DELIMITER_3}" '"'
|
||||
}
|
||||
|
||||
# TODO: separation of concerns
|
||||
|
|
|
@ -46,7 +46,7 @@ coll::add() {
|
|||
}
|
||||
|
||||
coll::reverse() {
|
||||
tac
|
||||
str::reverse_lines "$@"
|
||||
}
|
||||
|
||||
coll::set() {
|
||||
|
|
|
@ -29,7 +29,7 @@ selection::cmd_or_comment() {
|
|||
else
|
||||
echo "$cheat" \
|
||||
| grep "^${core}$" -B999 \
|
||||
| tac \
|
||||
| str::reverse_lines \
|
||||
| str::last_paragraph_line
|
||||
fi
|
||||
}
|
||||
|
|
10
src/str.sh
10
src/str.sh
|
@ -35,3 +35,13 @@ str::index_last_occurrence() {
|
|||
|
||||
awk 'BEGIN{FS=""}{ for(i=1;i<=NF;i++){ if($i=="'"$char"'"){ p=i } }}END{ print p }'
|
||||
}
|
||||
|
||||
str::reverse_lines() {
|
||||
if command_exists tac; then
|
||||
tac
|
||||
elif command_exists perl; then
|
||||
perl -e 'print reverse <>'
|
||||
else
|
||||
awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }'
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue