-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminecraft-colorscripts.sh
More file actions
executable file
·90 lines (81 loc) · 2.1 KB
/
minecraft-colorscripts.sh
File metadata and controls
executable file
·90 lines (81 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env sh
SCRIPT_DIR=$( dirname -- "$( readlink -f -- "$0"; )"; )
BLOCKS_DIR="$SCRIPT_DIR/colorscripts/"
SELECTED_PACK="default-1.8.9"
_help() {
echo "Print the unicode version of minecraft blocks in your shell"
echo ""
echo "Usage: minecraft-colorscripts [OPTION] [BLOCK NAME]"
echo " -h \t Print this help menu."
echo " -r \t Print a random block."
echo " -l \t Print a list of all blocks."
echo " -n NAME Print a block by name. Generally spelled like in the game."
echo " -w \t Print a random wool block."
echo " -t \t Print a random block and its name."
echo " -p \t Print a list of all texture packs."
}
_show_block_by_name() {
block_name=$1
cat "$BLOCKS_DIR/$SELECTED_PACK/$block_name.txt" 2>/dev/null || echo "Invalid block"
}
_show_random_block() {
cat $(shuf -n1 -e $BLOCKS_DIR/$SELECTED_PACK/*)
}
_show_random_block_n_title() {
block_file=$(shuf -n1 -e $BLOCKS_DIR/$SELECTED_PACK/*)
block_name=$(basename $block_file .txt)
_show_block_by_name $block_name
echo $block_name
}
_list_block_names() {
ls -1 $BLOCKS_DIR/$SELECTED_PACK/ | sed -e 's/\.txt$//'
}
_show_random_wool_block() {
cat $(shuf -n1 -e $BLOCKS_DIR/$SELECTED_PACK/wool_colored*)
}
_list_texture_packs() {
ls -1 $BLOCKS_DIR/
}
case "$#" in
0)
_help
;;
1)
case $1 in
-h)
_help
;;
-r)
_show_random_block
;;
-l)
_list_block_names
;;
-w)
_show_random_wool_block
;;
-t)
_show_random_block_n_title
;;
-p)
_list_texture_packs
;;
*)
echo "Input error."
exit 1
;;
esac
;;
2)
if [ "$1" = '-n' ]; then
_show_block_by_name "$2"
else
echo "Input error."
exit 1
fi
;;
*)
echo "Input error, too many arguments."
exit 1
;;
esac