navi/tests/no_prompt_cheats/cases.cheat

105 lines
2.1 KiB
Text
Raw Normal View History

; author: CI/CD
% test, first
# trivial case -> "foo"
echo "foo"
2023-04-09 00:45:38 +00:00
# map with underscores -> "_foo_"
2021-08-07 13:52:30 +00:00
echo "<map1>"
# expand -> "foo"
echo "<expand1>"
# duplicated lines -> "foo\nlorem ipsum\nlorem ipsum\nbaz"
echo foo
echo lorem ipsum
echo lorem ipsum
echo baz
# empty line -> "foo\n\n\nbar"
echo "$(cat <<EOF
foo
bar
EOF
)"
2021-08-07 13:52:30 +00:00
# sed with replacement -> "172.17.0.2"
echo "8.8.8.8 via 172.17.0.1 dev eth0 src 172.17.0.2" | sed -E 's/.*src ([0-9.]+).*/\1/p' | head -n1
# 2nd column with default delimiter -> "rust is cool"
echo "<language> is cool"
# 2nd column with custom delimiter -> "clojure is cool"
echo "<language2> is cool"
# multiple words -> "lorem foo bar ipsum"
echo "lorem <multiword> ipsum"
# variable dependency, full -> "2 12 a 2"
echo "<x> <x2> <y> <x>"
; # variable dependency, we can ignore intermediate values -> "foo 12"
; printf "foo "; : <x>; echo "<x2>"
# nested unused value -> "path: /my/pictures"
echo "path: <pictures_folder>"
2021-01-18 16:03:39 +00:00
# multiline command: no backslash -> "foo\nbar"
echo "foo"
echo "bar"
# multiline command: with backslash -> "lorem ipsum\nno match"
echo 'lorem ipsum'
echo "foo" \
| grep -q "bar" \
&& echo "match" \
|| echo "no match"
# multiline variable -> "foo bar"
echo "<multilinevar>"
# helper -> "inside helper: 42"
myhelperfn 42
$ x: echo '2'
$ x2: echo "$((x+10))"
$ y: echo 'a'
$ language: echo '0 rust rust-lang.org' --- --column 2
$ language2: echo '1;clojure;clojure.org' --- --column 2 --delimiter ';'
$ multiword: echo 'foo bar'
$ pictures_folder: echo "/my/pictures"
2021-08-07 13:52:30 +00:00
$ map1: echo "foo" --- --map 'echo _$(cat)_'
$ multilinevar: echo "xoo yar" \
| tr 'x' 'f' \
| tr 'y' 'b'
2021-08-07 13:52:30 +00:00
$ expand1: echo "foo" --- --expand
# this should be displayed -> "hi"
echo hi
% test, second
@ test, first
@ test, third
# nested used value -> "path: /my/pictures/wallpapers"
echo "path: <wallpaper_folder>"
# same command as before -> "12"
: <x>; echo "<x2>"
# the order isn't relevant -> "br"
echo "<country>"
$ wallpaper_folder: echo "<pictures_folder>/wallpapers"
% test, third
; this cheathsheet doesn't have any commands
$ country: echo "br"