From 638a3d2fc94de4410b130880c1a9c5c389f62912 Mon Sep 17 00:00:00 2001 From: Denis Isidoro Date: Sun, 22 Sep 2019 12:10:51 -0300 Subject: [PATCH] Fix preview --- cheats/git.cheat | 2 +- navi | 2 +- src/opts.sh | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cheats/git.cheat b/cheats/git.cheat index 7913d94..957239b 100644 --- a/cheats/git.cheat +++ b/cheats/git.cheat @@ -29,7 +29,7 @@ git add git add . # Saves the changes to a file in a commit -git commit -m "" +git commit -m # Pushes committed changes to remote repository git push -u diff --git a/navi b/navi index 83d37cc..d3b3923 100755 --- a/navi +++ b/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.8.0" +VERSION="0.8.1" opts::eval "$@" main "$@" diff --git a/src/opts.sh b/src/opts.sh index 552406d..a96a7fd 100644 --- a/src/opts.sh +++ b/src/opts.sh @@ -6,6 +6,16 @@ opts::extract_help() { grep "^##?" "$file" | cut -c 5- } +opts::preview_hack() { + local readonly arg="$1" + + if [ ${arg:0:1} = "'" ]; then + echo "${arg:1:${#arg}-2}" + else + echo "$arg" + fi +} + opts::eval() { local readonly wait_for="" @@ -17,7 +27,7 @@ opts::eval() { for arg in "$@"; do case $wait_for in path) NAVI_PATH="$arg"; wait_for="" ;; - preview) query="$(echo "$arg" | tr "^" " ")"; wait_for=""; break ;; + preview) query="$(opts::preview_hack "$arg" | tr "^" " ")"; wait_for=""; break ;; search) query="$arg"; wait_for=""; export NAVI_PATH="${NAVI_PATH}:$(search::full_path "$query")"; ;; query) query="$arg"; wait_for="" ;; esac