NOTICKET: Upgrade Justfile
This commit is contained in:
parent
6df6115d92
commit
1e48fe13c9
2 changed files with 16 additions and 3 deletions
1
app/bin/just/.gitignore
vendored
Normal file
1
app/bin/just/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
.cache/
|
|
@ -9,9 +9,9 @@ function preview() {
|
||||||
if [[ -z "$recipe" ]] || echo $recipe | grep -q "^\["; then
|
if [[ -z "$recipe" ]] || echo $recipe | grep -q "^\["; then
|
||||||
printf "${RED_FG}Select this to Exit${CLEAR}"
|
printf "${RED_FG}Select this to Exit${CLEAR}"
|
||||||
elif [[ "$content" == *" ..." ]]; then
|
elif [[ "$content" == *" ..." ]]; then
|
||||||
just_wrapper --list $recipe | highlight --out-format xterm256 --syntax conf
|
hash_highlight "$(just_wrapper --list $recipe)" "conf"
|
||||||
else
|
else
|
||||||
just_wrapper --show $recipe | highlight --out-format xterm256 --syntax sh
|
hash_highlight "$(just_wrapper --show $recipe)" "sh"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,19 @@ function choose_truncate() {
|
||||||
function choose_list() {
|
function choose_list() {
|
||||||
just_wrapper -l --no-aliases --list-heading="" | awk '{$1=$1};1'
|
just_wrapper -l --no-aliases --list-heading="" | awk '{$1=$1};1'
|
||||||
}
|
}
|
||||||
|
function hash_highlight() {
|
||||||
|
cache_dir="$(dirname ${BASH_SOURCE[0]})/.cache"
|
||||||
|
hash=$(echo $1 | md5sum | cut -d ' ' -f1)
|
||||||
|
file="$cache_dir/$hash"
|
||||||
|
if [[ -e $file ]]; then
|
||||||
|
cat $file
|
||||||
|
else
|
||||||
|
mkdir -p $cache_dir
|
||||||
|
data=$(printf "$1" | highlight --out-format xterm256 --syntax "$2")
|
||||||
|
printf "$data"
|
||||||
|
printf "$data" > $file
|
||||||
|
fi
|
||||||
|
}
|
||||||
case "$action" in
|
case "$action" in
|
||||||
*choose) choose;;
|
*choose) choose;;
|
||||||
*preview) preview;;
|
*preview) preview;;
|
||||||
|
|
Loading…
Reference in a new issue