mirror of
https://github.com/denisidoro/navi
synced 2024-11-21 19:13:07 +00:00
parent
a70c6dfadd
commit
e9dc75555b
7 changed files with 11 additions and 8 deletions
2
navi
2
navi
|
@ -4,7 +4,7 @@ set -euo pipefail
|
|||
export NAVI_HOME="$(cd "$(dirname "$0")" && pwd)"
|
||||
source "${NAVI_HOME}/src/main.sh"
|
||||
|
||||
VERSION="0.18.0"
|
||||
VERSION="0.18.1"
|
||||
NAVI_ENV="${NAVI_ENV:-prod}"
|
||||
|
||||
opts::eval "$@"
|
||||
|
|
|
@ -67,6 +67,8 @@ arg::serialize_code() {
|
|||
printf "tr \"'\" '${ESCAPE_CHAR_2}'"
|
||||
printf " | "
|
||||
printf "tr '\"' '${ESCAPE_CHAR_3}'"
|
||||
printf " | "
|
||||
printf "tr '\\\\' '${ESCAPE_CHAR_4}'"
|
||||
}
|
||||
|
||||
arg::pick() {
|
||||
|
|
0
src/cheat.sh
Executable file → Normal file
0
src/cheat.sh
Executable file → Normal file
|
@ -1,11 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
cmd::escape() {
|
||||
tr '\\' "$ESCAPE_CHAR_3"
|
||||
tr '\\' "$ESCAPE_CHAR_4"
|
||||
}
|
||||
|
||||
cmd::unescape() {
|
||||
tr "$ESCAPE_CHAR_3" '\\'
|
||||
tr "$ESCAPE_CHAR_4" '\\'
|
||||
}
|
||||
|
||||
cmd::loop() {
|
||||
|
@ -50,4 +50,4 @@ cmd::finish() {
|
|||
else
|
||||
eval "$cmd"
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ selection_str::comment() {
|
|||
}
|
||||
|
||||
selection_str::snippet() {
|
||||
echo "$*" | awk -F "${SELECTION_ESCAPE_STR}" '{print $2}' | selection_str::without_ellipsis
|
||||
echo "$*" | awk -F "${SELECTION_ESCAPE_STR}" '{print $2}' | selection_str::without_ellipsis | cmd::escape
|
||||
}
|
||||
|
||||
selection_str::tags() {
|
||||
|
@ -72,4 +72,4 @@ selection::tags() {
|
|||
selection::key() {
|
||||
local -r selection="$1"
|
||||
dict::get "$selection" key
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
ESCAPE_CHAR="\034"
|
||||
ESCAPE_CHAR_2="\035"
|
||||
ESCAPE_CHAR_3="\036"
|
||||
ESCAPE_CHAR_4="\037"
|
||||
|
||||
str::length() {
|
||||
awk '{print length}'
|
||||
|
@ -82,4 +83,4 @@ str::as_column() {
|
|||
|
||||
str::with_line_numbers() {
|
||||
awk '{printf("%d %s\n", NR,$0)}'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ ui::select() {
|
|||
[[ "${SHELL:-}" =~ 'fish' ]] || local -r sub='$'
|
||||
|
||||
local -r script_path="${NAVI_HOME}/navi"
|
||||
local -r preview_cmd="\"${script_path}\" preview ${sub:-}(echo \'{}\' | $(arg::serialize_code))"
|
||||
local -r preview_cmd="\"${script_path}\" preview ${sub:-}(echo \'{}\' | $(arg::serialize_code) 2> /dev/null)"
|
||||
|
||||
local -r query="$(dict::get "$OPTIONS" query)"
|
||||
local -r entry_point="$(dict::get "$OPTIONS" entry_point)"
|
||||
|
|
Loading…
Reference in a new issue