feat: add source field to each cheatpath to describe cheatsheet's source, use cheatsheet helper script to init cheatsheet

This commit is contained in:
Lonenso 2022-03-19 21:51:47 +08:00
parent 12ffa4cb5c
commit 5513724232
1 changed files with 19 additions and 0 deletions

View File

@ -1,4 +1,18 @@
#!/bin/sh -e #!/bin/sh -e
init() {
readarray d < <(yq -c '.cheatpaths[]' ~/.cheat.yml)
for c in "${d[@]}";
do
name="$(echo ${c} | yq -r '.name')"
path="$(echo ${c} | yq -r '.path')"
src="$( echo ${c} | yq -r '.source')"
echo "Init $name"
[ ! -d "$path" ] && git clone $src $path || :
done
echo "Finished init"
}
pull() { pull() {
for d in `cheat -d | awk '{print $2}'`; for d in `cheat -d | awk '{print $2}'`;
@ -36,8 +50,13 @@ if [ "$1" = "pull" ]; then
pull pull
elif [ "$1" = "push" ]; then elif [ "$1" = "push" ]; then
push push
elif [ "$1" = "init" ]; then
init
else else
echo "Usage: echo "Usage:
# init cheatsheets
cheatsheets init
# pull changes # pull changes
cheatsheets pull cheatsheets pull