Improve README (#1)

This commit is contained in:
Denis Isidoro 2019-09-20 14:42:51 -03:00 committed by GitHub
parent 132aee10ce
commit 5a00cb4417
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 9 deletions

View file

@ -6,7 +6,7 @@ An interactive cheatsheet tool for the command-line so that you'll never say the
*- Oh, it's not in my bash history* *- Oh, it's not in my bash history*
*- Geez, it's almost what I wanted but I need to change some args* *- Geez, it's almost what I wanted but I need to change some args*
![Demo](https://user-images.githubusercontent.com/3226564/65281359-d158f480-db08-11e9-8e69-e380d76c343b.gif) ![Demo](https://user-images.githubusercontent.com/3226564/65347073-8dbbc480-dbb4-11e9-886f-0f10d56def74.gif)
**navi** allows you to browse through cheatsheets (that you may write yourself or downloaded from maintainers) and execute commands, prompting for argument values. **navi** allows you to browse through cheatsheets (that you may write yourself or downloaded from maintainers) and execute commands, prompting for argument values.

2
navi
View file

@ -22,6 +22,6 @@ source "${SCRIPT_DIR}/src/main.sh"
##? --print Prevent script execution [default: false] ##? --print Prevent script execution [default: false]
##? --no-interpolation Prevent argument interpolation [default: false] ##? --no-interpolation Prevent argument interpolation [default: false]
VERSION="0.3.0" VERSION="0.4.0"
docs::eval "$@" docs::eval "$@"
main "$@" main "$@"

View file

@ -11,10 +11,10 @@ cheat::read_many() {
printf("\033[%dm%s\033[0m",30+c,s) printf("\033[%dm%s\033[0m",30+c,s)
} }
/^%/ { tags=substr($0, 3); next } /^%/ { tags=" ["substr($0, 3)"]"; next }
/^#/ { print color(3, tags"^") color(4, $0); next } /^#/ { print color(4, $0) color(60, tags); next }
/^\$/ { next } /^\$/ { next }
NF { print color(3, tags"^") color(7, $0); next }' "$cheat" NF { print color(7, $0) color(60, tags); next }' "$cheat"
done done
} }

View file

@ -1,11 +1,20 @@
#!/usr/bin/env bash #!/usr/bin/env bash
selection::standardize() {
local readonly str="$(cat)"
local readonly tags="$(echo "$str" | awk -F'[' '{print $NF}' | tr -d ']')"
local readonly core="$(echo "$str" | sed -e "s/ \[${tags}\]$//")"
echo "${core}^${tags}"
}
selection::core() { selection::core() {
cut -d'^' -f2 cut -d'^' -f1
} }
selection::tags() { selection::tags() {
cut -d'^' -f1 cut -d'^' -f2
} }
selection::core_is_comment() { selection::core_is_comment() {

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
ui::pick() { ui::pick() {
fzf --inline-info "$@" fzf --height '100%' --inline-info "$@"
} }
ui::select() { ui::select() {
@ -9,7 +9,8 @@ ui::select() {
echo "$cheats" \ echo "$cheats" \
| cheat::read_many \ | cheat::read_many \
| ui::pick -i --ansi --delimiter '\^' --with-nth 2 | ui::pick -i --ansi \
| selection::standardize
} }
ui::clear_previous_line() { ui::clear_previous_line() {