forked from arpitbbhayani/py-prompts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpy-prompts
executable file
·60 lines (52 loc) · 1.38 KB
/
py-prompts
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
#!/bin/sh
set -e
command=$1
print_help() {
echo "Available commands:"
echo ""
echo "\033[1;33mls\033[0m - lists all available themes"
echo "\033[1;33mset\033[0m - applies a theme"
}
print_list() {
echo ""
echo "Available prompt themes:\033[0;34m"
ls $HOME/.py-prompts/themes | rev | cut -d "." -f 2- | rev | tr '\n' ','
echo "\033[0m"
}
if [ -z $command ]; then
print_help
exit 1
fi
if [ "$command" = "help" ]; then
print_help
exit 0
fi
if [ "$command" = "ls" ]; then
print_list
exit 0
fi
if [ "$command" = "set" ]; then
theme_name=$2
if [ -z "$theme_name" ]; then
echo "\033[1;33musage: py-prompts set <theme_name>\033[0m"
print_list
else
echo "Setting theme \033[1;33m$theme_name\033[0m"
if [ ! -f "$HOME/.py-prompts/themes/$theme_name.py" ]; then
echo "\033[0;31mtheme $theme_name does not exist.\033[0m"
print_list
exit 1
fi
if [ -f $HOME/.bashrc ]; then
echo "export PYTHONSTARTUP=$HOME/.py-prompts/themes/$theme_name.py" >> $HOME/.bashrc
elif [ -f $HOME/.zshrc ]; then
echo "export PYTHONSTARTUP=$HOME/.py-prompts/themes/$theme_name.py" >> $HOME/.zshrc
else
echo "\033[0;31mCould not detect your rc file. kindly add the following line in your rc file.\033[0m"
echo "\033[0;34mexport PYTHONSTARTUP=$HOME/.py-prompts/themes/$theme_name.py\033[0m"
fi
fi
exit 0
fi
print_help
exit 1