mirror of
https://github.com/denisidoro/navi.git
synced 2024-09-19 14:27:17 +03:00
Show comment for command in preview window (#98)
This commit is contained in:
parent
a485030355
commit
97329b97f6
@ -6,28 +6,28 @@ brew update
|
|||||||
# upgrade brew
|
# upgrade brew
|
||||||
brew upgrade
|
brew upgrade
|
||||||
|
|
||||||
# brew info
|
# get info for a package
|
||||||
brew info <package>
|
brew info <package>
|
||||||
|
|
||||||
# brew cask info
|
# get info for a cask
|
||||||
brew cask info <casks>
|
brew cask info <casks>
|
||||||
|
|
||||||
# brew install
|
# install a package
|
||||||
brew install <package>
|
brew install <package>
|
||||||
|
|
||||||
# brew caks install
|
# install a cask
|
||||||
brew cask install <casks>
|
brew cask install <casks>
|
||||||
|
|
||||||
# brew uninstall
|
# uninstall a package
|
||||||
brew uninstall <installed>
|
brew uninstall <installed>
|
||||||
|
|
||||||
# brew cask uninstall
|
# uninstall a cask
|
||||||
brew cask uninstall <caskinstalled>
|
brew cask uninstall <caskinstalled>
|
||||||
|
|
||||||
# brew edit package
|
# edit package
|
||||||
brew edit <package>
|
brew edit <package>
|
||||||
|
|
||||||
# brew edit cask
|
# edit cask
|
||||||
brew cask edit <casks>
|
brew cask edit <casks>
|
||||||
|
|
||||||
$ package: brew search
|
$ package: brew search
|
||||||
|
2
navi
2
navi
@ -35,7 +35,7 @@ source "${SCRIPT_DIR}/src/main.sh"
|
|||||||
##? full docs
|
##? full docs
|
||||||
##? Please refer to the README at https://github.com/denisidoro/navi
|
##? Please refer to the README at https://github.com/denisidoro/navi
|
||||||
|
|
||||||
VERSION="0.10.2"
|
VERSION="0.10.3"
|
||||||
NAVI_ENV="${NAVI_ENV:-prod}"
|
NAVI_ENV="${NAVI_ENV:-prod}"
|
||||||
|
|
||||||
opts::eval "$@"
|
opts::eval "$@"
|
||||||
|
@ -4,18 +4,15 @@ set -euo pipefail
|
|||||||
debian="${1:-false}"
|
debian="${1:-false}"
|
||||||
|
|
||||||
if $debian; then
|
if $debian; then
|
||||||
docker run \
|
image="debian"
|
||||||
-it \
|
setup_cmd="apt update; apt install -y git curl;"
|
||||||
--entrypoint /bin/bash \
|
|
||||||
-v "$(pwd):/navi" \
|
|
||||||
debian \
|
|
||||||
-c 'apt update; apt install -y git curl; git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && yes | ~/.fzf/install; export PATH=$PATH:/navi; bash'
|
|
||||||
else
|
else
|
||||||
docker run \
|
image="ellerbrock/alpine-bash-git"
|
||||||
-it \
|
|
||||||
--entrypoint /bin/bash \
|
|
||||||
-v "$(pwd):/navi" \
|
|
||||||
ellerbrock/alpine-bash-git \
|
|
||||||
-c 'git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && yes | ~/.fzf/install; export PATH=$PATH:/navi; bash'
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
docker run \
|
||||||
|
-it \
|
||||||
|
--entrypoint /bin/bash \
|
||||||
|
-v "$(pwd):/navi" \
|
||||||
|
"$image" \
|
||||||
|
-c "${setup_cmd:-}git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && yes | ~/.fzf/install; export PATH=$PATH:/navi; bash"
|
@ -48,7 +48,7 @@ dict::assoc() {
|
|||||||
local -r value="$(echo "${2:-}" | dict::_escape_value)"
|
local -r value="$(echo "${2:-}" | dict::_escape_value)"
|
||||||
|
|
||||||
shift 2
|
shift 2
|
||||||
echo "$(echo "$input" | dict::dissoc "$key")${key}: ${value}\n" | dict::assoc "$@"
|
echo "$(echo "$input" | dict::dissoc "$key")${key}: ${value}\n" | dict::assoc "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
dict::get() {
|
dict::get() {
|
||||||
|
@ -67,7 +67,7 @@ handler::preview() {
|
|||||||
local -r selection="$(echo "$query" | selection::dict)"
|
local -r selection="$(echo "$query" | selection::dict)"
|
||||||
local -r cheats="$(cheat::memoized_read_all)"
|
local -r cheats="$(cheat::memoized_read_all)"
|
||||||
local -r cheat="$(cheat::from_selection "$cheats" "$selection")"
|
local -r cheat="$(cheat::from_selection "$cheats" "$selection")"
|
||||||
[ -n "$cheat" ] && selection::cmd "$selection" "$cheat"
|
[ -n "$cheat" ] && selection::cmd_or_comment "$selection" "$cheat"
|
||||||
}
|
}
|
||||||
|
|
||||||
handler::help() {
|
handler::help() {
|
||||||
|
@ -13,9 +13,10 @@ selection::core_is_comment() {
|
|||||||
grep -qE '^#'
|
grep -qE '^#'
|
||||||
}
|
}
|
||||||
|
|
||||||
selection::cmd() {
|
selection::cmd_or_comment() {
|
||||||
local -r selection="$1"
|
local -r selection="$1"
|
||||||
local -r cheat="$2"
|
local -r cheat="$2"
|
||||||
|
local -r always_cmd="${3:-false}"
|
||||||
|
|
||||||
local -r core="$(echo "$selection" | dict::get core)"
|
local -r core="$(echo "$selection" | dict::get core)"
|
||||||
|
|
||||||
@ -23,7 +24,16 @@ selection::cmd() {
|
|||||||
echo "$cheat" \
|
echo "$cheat" \
|
||||||
| grep "$core" -A999 \
|
| grep "$core" -A999 \
|
||||||
| str::last_paragraph_line
|
| str::last_paragraph_line
|
||||||
else
|
elif $always_cmd; then
|
||||||
echo "$core"
|
echo "$core"
|
||||||
|
else
|
||||||
|
echo "$cheat" \
|
||||||
|
| grep "^${core}$" -B999 \
|
||||||
|
| tac \
|
||||||
|
| str::last_paragraph_line
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selection::cmd() {
|
||||||
|
selection::cmd_or_comment "$@" true
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user