navi/tests/cheats/more_cases.cheat

83 lines
2 KiB
Text
Raw Normal View History

2020-03-18 11:38:13 +00:00
; author: CI/CD
2020-03-05 18:06:31 +00:00
2020-03-18 11:38:13 +00:00
% test, ci/cd
# escape code + subshell
2020-03-05 18:06:31 +00:00
echo -ne "\033]0;$(hostname)\007"
2020-03-18 11:38:13 +00:00
# env var
echo "$HOME"
# multi + column
myfn() {
for i in $@; do
echo -e "arg: $i\n"
done
}
folders=($(echo "<multi_col>"))
myfn "${folders[@]}"
2020-03-18 11:38:13 +00:00
# second column: default delimiter
echo "<table_elem> is cool"
# second column: custom delimiter
echo "<table_elem2> is cool"
# return multiple results: single words
echo "I like these languages: "$(printf '%s' "<langs>" | tr '\n' ',' | sed 's/,/, /g')""
# return multiple results: multiple words
echo "I like these examples: "$(printf '%s' "<examples>" | sed 's/^..*$/"&"/' | awk 1 ORS=', ' | sed 's/, $//')""
# multiple replacements -> "foo"
2020-03-18 11:38:13 +00:00
echo "<x> <y> <x> <z>"
# with preview
cat "<file>"
# with map
echo "<mapped>"
# empty
echo "http://google.com?q=<query>"
# fzf
ls / | fzf
#
echo description space
#
echo description blank
# x
echo description one character
# map can be used to expand into multiple arguments
echo <phrases>
# Concatenate pdf files
files=($(echo "<files>"))
echo pdftk "${files[@]:-}" cat output <pdf_output>
$ files: echo 'file1.pdf file2.pdf file3.pdf' | tr ' ' '\n' --- --multi --overrides '--tac'
2020-03-18 11:38:13 +00:00
$ x: echo '1 2 3' | tr ' ' '\n'
$ y: echo 'a b c' | tr ' ' '\n'
$ z: echo 'foo bar' | tr ' ' '\n'
$ table_elem: echo -e '0 rust rust-lang.org\n1 clojure clojure.org' --- --column 2
$ table_elem2: echo -e '0;rust;rust-lang.org\n1;clojure;clojure.org' --- --column 2 --delimiter ';'
$ multi_col: ls -la | awk '{print $1, $9}' --- --column 2 --delimiter '\s' --multi
2020-03-18 11:38:13 +00:00
$ langs: echo 'clojure rust javascript' | tr ' ' '\n' --- --multi
$ mapped: echo 'true false' | tr ' ' '\n' --- --map "[[ $1 == t* ]] && echo 1 || echo 0"
$ examples: echo -e 'foo bar\nlorem ipsum\ndolor sit' --- --multi
$ multiword: echo -e 'foo bar\nlorem ipsum\ndolor sit\nbaz'i
$ file: ls . --- --preview 'cat {}' --preview-window 'right:50%'
$ phrases: echo -e "foo bar\nlorem ipsum\ndolor sit" --- --multi --map "sed -e 's/^.*$/\"&\"/' | tr '\n' ' '"
2020-03-18 11:38:13 +00:00
# this should be displayed
echo hi
%
# Without tag
echo hi 1 2 3